#clojure log - Mar 01 2009

The Joy of Clojure
Main Clojure site
Google Group
IRC
List of all logged dates

1:32 banisterfiend: can someone tell me how to setup clojure in linux?

1:35 ayrnieu: banister - go to clojure.org, click on 'wiki' at the top-right, go to Getting Started.

1:41 banisterfiend: can you please help me though instead

1:46 cp2: banisterfiend not much to setup

1:46 all you need is java

1:46 and then you can either grab the source from the svn and build it, or download the latest release

1:46 banisterfiend: which do you recommend?

1:46 source or latest release?

1:46 cp2: doesnt matter really

1:46 banisterfiend: (and how long does the source take to build?)

1:46 cp2: building from source isnt necessarily "stable"

1:47 it builds pretty quickly

1:47 cmvkk: on the other hand, some pretty significant changes have occurred since the last real release?

1:47 cp2: yeah, that is true

1:47 banisterfiend: ill build from source

1:47 cp2: banisterfiend, i also recommend what ayrnieu told you to do

1:47 the wiki is a great place to start at

1:48 banisterfiend: can i use clojure with slime?

1:48 cp2: there is clojure-slime

1:48 banisterfiend: is emacs the recommended clojure editor?

1:48 cp2: and also clojure-mode

1:48 and swank-clojure

1:48 well, banisterfiend, its up to you in the end

1:48 banisterfiend: yeah

1:48 just curious what most ppl are using though :)

1:48 ayrnieu: I did all my clojure editing with vi.

1:49 banisterfiend: what is the javac package called?

1:49 it says i need javac

1:49 but apt-get install javac doesn't do the trick

1:49 cp2: jdc

1:49 er

1:49 jdk

1:49 *

1:49 banisterfiend: thanks

1:50 cp2: javac is included in the jdk

1:50 but, the package is not labeled jdk probably

1:50 what package manager?

1:50 oh right, apt

1:50 banisterfiend: apt

1:50 cp2: apt-get install sun-jdk iirc

1:51 banisterfiend: apt-get install sun-java6-jdk ?

1:51 cp2: yes thats it

1:51 banisterfiend: (i dont know anything about java sorry)

1:51 java6 rather than java5 ?

1:52 cp2: java6 is the latest

1:52 banisterfiend: ok thanks

1:52 cp2: you could have java5 if you want, but it lacks some newer features

1:52 nothing too special though

1:52 banisterfiend: like templates?

1:52 cp2: generics* were introduced in java 5

1:52 clojure will build in either tho

1:53 banisterfiend: generics are the java word for templates?

1:53 cp2: pretty much

1:53 banisterfiend: last time i looked at some java code

1:53 seems like it's getting pretty much as complicated as c++

1:53 cp2: eh, not so much

1:54 banisterfiend: so

1:54 hmm

1:54 is clojure really so good for multi-core systems?

1:55 cp2: i dont know; maybe a more competent person can answer :)

1:55 banisterfiend: you're new to clojure too?

1:55 cp2: somewhat

1:56 banisterfiend: new to lisps too?

1:56 cp2: somewhat

1:56 heh

1:57 banisterfiend: so what about clojure appealed to you?

1:58 cp2: i dont know, i was always curious about lisps

1:59 started learning cl, but never really did anything with it

1:59 then i found out about clojure, and like it because it used the java library

1:59 coming from java, that was appealing

1:59 being able to use a library i was familiar with

2:00 banisterfiend: what other languages do you know besides java? which dynamic ones esp? :D

2:03 cp2: pretty much python and ruby

2:03 and i wouldnt go as far as "know"

2:06 banisterfiend: ah ok

2:06 which do you prefer out of python and ruby?

2:07 cp2: i havent used either enough to say for sure, but i will go with python

2:07 banisterfiend: wow so you're pretty much just a java programmer?!

2:08 cp2: well, was

2:08 i had a fling with C# too

2:08 banisterfiend: what have you set things up to run the clojure repl?

2:09 cp2: what ?

2:09 banisterfiend: i mean what do you type to run the repl?

2:09 cp2: you can use java -jar clojure.jar

2:09 and it will drop a repl

2:09 on the wiki it goes over using jline with clojure at a shell, which is a bit nicer to use

2:21 banisterfiend: ok

2:21 how do i get ant to do the equivalent of a 'make install' to install clojure system wide?

2:22 cp2: well, you dont really need to install clojure, its just a java library after all

2:22 i suppose you could put it in a directory thats in PATH

2:22 banisterfiend: oh ok

2:22 im qutie new to linux

2:22 cp2: so you can just java -cp clojure.jar:. clojure.main somefile.clj

2:23 banisterfiend: how/where should i put the clj bash script so that i can run it from anywhere?

2:23 cp2: /usr/bin

2:23 banisterfiend: oh ok

2:23 thanks

2:23 cp2: make sure you chmod to a+x as well

2:25 banisterfiend: thanks

2:45 can someone give me a quick factorial example function in clojure?

2:45 (nothing clever using apply or whatever, just a simple recursive) :D

2:49 cmvkk: (defn fact [i] (loop [i i res 1] (if (< i 2) res (recur (dec i) (* res i))))

2:51 replaca: Simpler is this: (defn fact [n] (if (<= n 1) 1 (* n (fact (dec n)))))

2:51 but it's not as optimal, since java doesn't know how to optimize it

2:51 cmvkk: true; i automatically disregard solutions that aren't tail recursive now apparently?

2:52 replaca: strictly speaking, that is tail recursize :-)

2:52 *recursive

2:52 cmvkk: actually it isn't; fact's return still has to multiply against n.

2:53 otherwise you could use recur there, but if you try that it won't work.

2:53 replaca: oh yeah, you're right

2:54 but I think a good CL compiler would still optimize it, wouldn't it?

2:54 cmvkk: well you can't optimise a solution that isn't tail recursive so that it won't blow the stack.

2:55 replaca: hmmm

2:55 banisterfiend: thanks replaca

2:55 cmvkk: because you have to store that last "* n" somewhere...

2:55 and that somewhere is on the stack.

2:56 replaca: now I'm having to think too hard for this late on a Saturday night :-)

2:56 banisterfiend: no problem

2:56 cmvkk: i was going to say, i'm not actually sure; maybe there IS a way or something.

2:57 replaca: well, it seems optimizable in this case, but I don't know if it generalizes

2:57 since you could basically analyze it out into a loop

2:59 but a quick check shows me that sbcl can't do it, so I guess it "isn't done"

3:00 cmvkk: yeah; although possible, it doesn't seem feasable in any general sense

3:00 replaca: Thanks for the clarification cmvkk - I thought that case got converted to TCO

3:01 so I just learned something! :-)

3:08 jhujhiti: anyone using vimclojure 1.3.0?

3:59 Lau_of_DK: Morning all

4:00 ImInYourMonad: is the ants example by rhickey an example of swarm intelligence algorithm or is it just concurrency?

4:01 Lau_of_DK: concurrency

4:11 ImInYourMonad: knn.Knn with constructor Knn, then i should (import '(knn.KNN Knn)) right?

4:11 knn.KNN with constructor Knn, then i should (import '(knn.KNN Knn)) right?

4:13 lenst: Wrong?

4:14 ImInYourMonad: well it doesnt work

4:14 but is it the correct syntax?

4:15 lenst: You should only import the class, not the constructor.

4:16 hmm. What is a constructor btw? Isn't a constructor in Java just the class name?

5:40 Lau_of_DK: Hmm, SofiaBA, running with fog, double-textured translucent water and detail-textured Imagebased heightmap + skybox, idles at ~650 fps :)

5:42 hoeck: Lau_of_DK: and your machine is a??

5:42 Lau_of_DK: Its a single-core AMD 4000+ with a Geforce 8600 GTS

5:43 It goes roughly at the same speed on my laptop also, nvidia MX something

5:44 hoeck: Regarding physics - I got everything imported, all classes instantiated, added both statics and dynamics to my rootnode and everything rendered - but the physics wasnt active somehow, the gravity didnt pull for instance, so after working with that for 2 days I decided to freeze it until I had provided more wrapper functionality

5:45 hoeck: aha, thanks for the info, was just about to ask :)

5:45 Lau_of_DK: If you want to contribute that functionality - you'd be most welcome :)

5:45 hoeck: at least, there is box2D + processing left for java-clojure 2D physics

5:45 Lau_of_DK: I always felt like I was THIS close

5:46 Hows that useful in this regard?

5:46 hoeck: only for 2D, but still fun

5:47 did you try the jme-physics example from their wiki?

5:47 Lau_of_DK: Thats the one I ported, almost directly

5:48 Then when that didnt work, I commented out every but the physics part, it rendered, but didnt respond to forces

5:49 But its a big step that it rendered, because that means that all physics nodes (static + dynamic) were intantiated correctly

5:53 hoeck: well, I'm giving it a try, repl-interactive physics sounds just too interesting to give up :)

6:02 Lau_of_DK: Yea, although I dont have the physics, its cool to navigate an interactive world, like what Im doing now

6:03 But I recommend that you stick close to the Github, Im updating alot of stuff these days

6:03 (adding particle support atm)

6:08 hoeck: last night i was busy with adding a better clojure-def-regexp to clojure-mode, so that speedbar and imenu will show correct definitions

6:10 Lau_of_DK: Youre contributing to technomancy's clojure-mode aswell ?

6:12 hoeck: no, just a local fork to keep xemacs compatibility

6:14 don't know if any xemacs and speedbar users are here

6:15 Lau_of_DK: k

6:18 Already got particles flying around - Im really feeling the rapid pace of Lisp development on this one now :)

6:21 hoeck: cool

6:21 bOR_: thanks rhickey :). 7 8-core computers crunching on simulations that take 13 hours each :). would have been horrible if I would be using a single core per simulation.

7:10 banisterfiend: what is a 'special form' ?

7:15 Lau_of_DK: As I understand it, its a form thats provided from neither a clojure-function/macro

7:18 rfgpfeiffer: ,`(let [def [1 2 3]] (def 2))

7:18 clojurebot: (clojure.core/let [def [1 2 3]] (def 2))

7:19 rfgpfeiffer: ,(let [def [1 2 3]] (def 2))

7:19 clojurebot: DENIED

7:19 rfgpfeiffer: banisterfiend: you can't rebind special forms, for example

7:20 ,(let [fn [1 2 3]] (fn 2))

7:20 clojurebot: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.UnsupportedOperationException: nth not supported on this type: Integer

7:23 rfgpfeiffer: ,([1 2 3] 2)

7:23 clojurebot: 3

7:24 rfgpfeiffer: ,'def

7:24 clojurebot: def

7:50 hoeck: Lau_of_DK: which revision of clojure are you using for SofiaBa?

8:13 Cheshire: hi clojeure

8:31 rhickey: Cheshire: hi

9:42 gnuvince_: Good morning

10:10 Lau_of_DK: hoeck: The one just before Lazy Town moved in

10:10 I think only 1 functions is affected

10:11 Is it easy enough to get running from the clone?

10:35 replaca: gnuvince_: you were asking about "status of pretty print" yesterday?

10:37 The core pretty print engine is all done, pretty printing data is all done, now I'm getting all the defiinitions for various code structures in

10:37 Should be ready for "preview release" RSN, but my day job has been a bear the last couple of months

10:41 gnuvince_: replaca: thanks

10:41 replaca: gnuvince_: np

10:47 gnuvince_: Does anyone have any recommendation for tutorials or books to quickly get up to speed with Swing?

12:09 blbrown: http://en.wikibooks.org/wiki/Clojure_Programming/Examples/API_Examples#proxy How do you implement a constructor with Proxy

12:11 kotarak: blbrown: you don't? With proxy you get an object, which behaves as specified, when calling the methods. Why would you want to implement a constructor for an object, which is already there?

12:12 blbrown: kotarak, maybe that is the intended purpose, but if I wanted to implement an abstract class and have access to protected methods through defining a constructor, you are saying I can't do that?

12:14 kotarak: blbrown: I'm not that solid in Java knowledge. I never tried to access protected methods via a proxy....

12:16 blbrown: hmm, according to the docs, I do have access to protected methods

12:16 kotarak: blbrown: Well. then it should be possible, no? I'm not sure, though, why you would need a constructor to do so.

12:18 blbrown: kotarak, I don't necessarilly need a constructor. but i need to call the protected method some how

12:18 kotarak: blbrown: is this method implemented by the super class? Then there is proxy-super (or something like this).

12:19 mattrepl: kotarak: was looking for that to post.. not finding it on site docs, must've seen it on list

12:20 blbrown: glad there aren't any usage examples in the clojure api docs

12:20 mattrepl: oh, no it's on the api page, just not on the java-interop page

12:21 http://clojure.org/api#toc408

12:21 ,(doc proxy-super)

12:21 clojurebot: "([meth & args]); Use to call a superclass method in the body of a proxy method. Note, expansion captures 'this"

12:36 Chouser: "Note that while method fns can be provided to override protected methods, they have no other access to protected members"

12:38 gnuvince_: Is -Xprof considerer accurate? Because it reports that one of the costliest functions in my code is PersistantVector.count, but I never call it (and as far as I know, count is supposed to be really fast)

12:41 durka42: PersistentVector.java:138 public int count(){ return cnt; }

12:41 blbrown: OK, this is what I am trying to do. Obviously I am doing that wrong, but at least it doesn't give me an error. http://paste.lisp.org/display/76325

12:41 p_l: gnuvince_: You sure it's never called? Is there any call graph tool available?

12:42 gnuvince_: 22.9% 3774 + 0 clojure.lang.PersistentVector.count

12:42 Chouser: blbrown: (doto (proxy [PircBot] []) (.setName "-->dog"))

12:42 durka42: i don't know how you do breakpoints in java, but you could edit PersistentVector::count to throw an exception, then you'd get a backtrace

12:43 gnuvince_: p_l: the better profiler (which takes ages to run) has very different numbers

12:45 blbrown: Chouser, setName is not found because it is protected

12:45 Chouser: blbrown: allow me to introduce you to gen-class

12:45 blbrown: bah

12:45 Chouser: I know. I'm sorry.

12:46 Lau_of_DK: Good evening gents

12:47 Chouser: all you would need is a class that extends PircBot, and provides public access to the protected members you need.

12:47 Then you could go ahead and use proxy on that new class instead.

12:47 Lau_of_DK: hi

12:47 Lau_of_DK: Yo Chris

12:48 Coaching the crowd on Gen-class again? :)

12:49 Chouser: :-(

12:49 Lau_of_DK: My solution worked out so great, that Im now doing gen-class in gen-class :)

12:50 Did you check out my latest screenshot Chouser, with the fog and everything?

12:50 Chouser: proxy teases with its ease of use, then suddenly betrays.

12:50 ah, nope, hadn't 'seen the fog.

12:51 those are nice clouds. do they move?

12:51 Lau_of_DK: They move when you move, its a skybox

12:51 rhickey: Chouser: is that :let for doseq ready for me to take? did you have any other thoughts on for unification?

12:51 Lau_of_DK: (im not happy with it yet though)

12:52 clojurebot: proxy is <Chouser> proxy teases with its ease of use, then suddenly betrays.

12:52 clojurebot: You don't have to tell me twice.

12:52 Lau_of_DK: Truer words are rarely spoken

12:52 Chouser: rhickey: don't use that, it's got a bug.

12:53 rhickey: ok

12:53 Chouser: still working on let. I think I've got it by the tail now...

12:53 er, for

12:57 mattrepl: Lau_of_DK: link to screenshot?

12:59 Chouser: mattrepl: http://wiki.github.com/Lau-of-DK/sofiaba

12:59 Lau_of_DK: http://wiki.github.com/Lau-of-DK/sofiaba

12:59 mattrepl: its a work in progress

13:00 mattrepl: Lau_of_DK: and I'm assuming this is jME? I'm curious if you've tried adding models to a scene after it was created. I've noticed issues with lighting

13:00 Lau_of_DK: Yea, in the current project you can press P to spawn a swarm on particles, and N to spawn a textured sphere with a picture of my daughter :) All works perfectly

13:01 mattrepl: heh, nice. =)

13:10 Lau_of_DK: hoeck: report

13:32 blbrown: hiredman you there?

13:34 Lau_of_DK: hoeck: report

13:37 hoeck: Lau_of_DK: segfaulted my vm

13:37 Lau_of_DK: really... Thats no good

13:37 Why are you on a VM ?

13:38 hoeck: regardless which renderer (lwjgl or jogl) was used

13:38 i mean my jvm :)

13:38 Lau_of_DK: Any way to deduct what kills it ?

13:38 Can you compile it?

13:38 hoeck: now I've just upgraded to jdk6.11

13:39 yeah, it compiles, then asks for screen resolution and such, then I see an empty frame, then the segfault

13:39 Lau_of_DK: Hmm

13:39 hoeck: somewhere when calling an openGL routine

13:40 Lau_of_DK: Have you tried the Webstart demos from JMonkeyengine.com ?

13:40 hoeck: no, that would be the next step

13:41 Lau_of_DK: Ok... Hope you can point your finger at something that breaks

13:41 You did read the README right?

13:41 cp2: hoeck it could be an opengl problem

13:42 Lau_of_DK: cp2: You got it running?

13:42 cp2: no, i dont know what you are talking about actually (the program i mean)

13:42 i know about jME, etc

13:42 link me, ill try it

13:42 hoeck: definetely a java-opengl problem (glxgears works)

13:43 Lau_of_DK: http://github.com/Lau-of-DK/sofiaba/tree/master

13:43 cp2: righto

13:43 give me a sec

13:44 Lau_of_DK: thanks

13:45 cp2: stupid tortoisegit

13:45 Lau_of_DK: Git rocks

13:45 Github is a little tortoise-like these days though

13:45 cp2: yeah, but tortoisegit (shell interface for windows)

13:46 right, now i need to get jme (again)

13:46 Lau_of_DK: hehe

13:47 I think LWJGL is included in the git clone

13:47 the deps/ needs to be in your library path, and the src/ in your classpath

13:49 cp2: googlecode svn not too fast today

13:51 Lau_of_DK yeah, lwjgl is in there

13:51 once less thing for me to grab

13:53 Lau_of_DK: man tortoisegit looks awful

13:53 cp2: yeah

13:53 then again, windows is pretty awful too

13:53 i just ended up opening a git bash shell

14:01 blbrown: PircBot hello

14:03 danlarkin: Lau_of_DK: Madison?

14:03 blbrown: Chouser funny, you have to connect to the server, change the nick then join the channel. with pircbot/clojure

14:04 ,(+ 1 1)

14:04 clojurebot: 2

14:04 blbrown: hehe [clojurebot] (n=PircBot@ip67-152-53-125.z53-152-67.customer.algx.net): PircBot 1.4.6 Java IRC Bot - www.jibble.org ...haha your name is really pircbot because hiredman didn't add code to change your name

14:06 Lau_of_DK: danlarkin: Its good :)

14:06 danlarkin: Lau_of_DK: madison it is, then!

14:07 Lau_of_DK: WEEEE! Its a big day today

14:07 cp2: ok, finally

14:07 got jme physics to build with much hassle

14:07 would be nice if ant didnt forcibly exit when its done

14:07 would also be nice to have known jmephysics needs jmetest

14:08 *sigh*

14:08 Lau_of_DK: cp2, I wrote out physics in the latest commit

14:08 so - You wont need it :(

14:08 cp2: ugh

14:08 Lau_of_DK: Sorry

14:08 cp2: didnt care to update your readme then

14:08 >:(

14:09 Lau_of_DK: No I just wrote it in one of todays commit, because I plan on bringing it back

14:09 * cp2 is an unhappy windows user

14:11 Lau_of_DK: ofc

14:15 cp2: java.lang.RuntimeException: java.lang.ClassNotFoundException: dk.bestinclass.sof

14:15 iaba$get_resource_uri__3164 (sofiaba.clj:12)

14:15 eh Lau_of_DK ?

14:16 it gets built at least

14:16 hold on

14:16 kotarak: cp2: maybe you should rebuilt the project. Failures like that indicate an incomplete jar or an inconsistent build.

14:17 cp2: kotarak i fixed that problem

14:17 but now

14:17 java.lang.Exception: Unable to resolve symbol: lazy-cons in this context (wrappe

14:17 rs.clj:59)

14:17 *sigh*

14:17 this is a fresh svn build of clojure too

14:17 (lazy-cons t (map (eval f) c))) ;; TODO: UPDATE TO LATEST REV OF CLOJURE

14:17 Lau_of_DK: cp2, lazy-cons = cons

14:17 Youre on a later revision than me

14:17 cp2: k, so just change it

14:17 ?

14:17 Lau_of_DK: just remove "lazy-"

14:17 yea

14:17 cp2: aye

14:18 hoeck: Lau_of_DK: did that replacement too :)

14:18 cp2: yay, it compiled

14:18 Lau_of_DK: What can I say - I had to wait for SLIME and SWANK :)

14:18 yay

14:18 hoeck: Lau_of_DK: but slime and swank works already with lazy

14:18 Lau_of_DK: Yea I know, now Im just waiting for me

14:18 hoeck: :)

14:20 cp2: of course, got all that set but i forgot to put lwjgl in classpath

14:20 Lau_of_DK: LIBRARY_PATH

14:20 not classpath

14:20 cp2: no, im not talking about the shared libraries

14:20 im talking about lwjgl.jar etc

14:21 Lau_of_DK: Also notice the "compile-it" function in sofiaba.clj, you need to adjust *compile-path*

14:21 hiredman: blbrown: ?

14:21 Lau_of_DK: k

14:22 cp2: ok Lau_of_DK, it runs

14:22 jme didnt prompt me to set anything thought :(

14:23 Lau_of_DK: cp2, the very last function in sofiaba.clj, change NeverShowConfig to AlwaysShowConfig and run again

14:23 cp2: ok

14:24 Lau_of_DK: But you see the island, and everything renders okay, you get an fps count?

14:24 cp2: yes

14:25 Lau_of_DK: cool

14:26 cp2 - Are you comfortable with jmephysics?

14:26 cp2: as in, can i use it?

14:26 er, write code for/with it rather

14:27 cp2: tbh i never really took the time to learn about jmephysics, and i never did much with jme

14:27 as for right now, i am going to go play some et :)

14:28 Lau_of_DK: Yea - I tried to integrate it, but I didnt fly - I got objects attached to dynamicphysicsnode / staticnodes, and everything rendered, but the physics didnt function

14:40 blbrown: hiredman, cool, you are back. In your clojure bot code, is there a way to call the protected methods of the pircbot api. E.g. I noticed that you didn't call setName in your code

15:01 Lau_of_DK: Chouser: Are you done porting this yet? http://muaddibspace.blogspot.com/2009/03/how-to-halve-number.html

15:03 hiredman: blbrown: no, I use proxy, so all the proxy provisos apply

15:03 Lau_of_DK: clojurebot: proxy?

15:03 clojurebot: proxy is <Chouser> proxy teases with its ease of use, then suddenly betrays.

15:04 hiredman: WFM

15:04 blbrown: hehe

15:04 Chouser: Lau_of_DK: what a waste.

15:04 blbrown: seems like it can do everything except access protected members and implement constructors

15:04 Chouser: and add new methods

15:05 blbrown: ...OK that too

15:05 Chouser: and produce specifically-named classes

15:05 blbrown: Chouser, ok, ok

15:05 kotarak: And when it can do all that, we rename it to gen-class. ;)

15:05 blbrown: kotarak, does gen-class work dynamically or do you need to compile

15:05 kotarak: You have to compile.

15:06 blbrown: hmm

15:23 rlb: Is there a better way to write (in the scheme/lisp sense) to a file than calling pr-str or prn-str and then writing that?

15:24 Lau_of_DK: There are many java-ways to write to a file, the right one depends on your purpose

15:24 rlb: Lau_of_DK: I just mean wrt clojure, i.e. since pr and prn only write to *out*, then it seemed like you probably needed to use pr-str or prn-str if you want to send the output somewhere else (unless clojure has some way to locally bind *out*).

15:25 Lau_of_DK: (with-out-str

15:25 (doc with-out-str)

15:25 clojurebot: Evaluates exprs in a context in which *out* is bound to a fresh StringWriter. Returns the string created by any nested printing calls.; arglists ([& body])

15:25 kotarak: rib: (binding [*out* something-else] ....)

15:25 rlb: Lau_of_DK: right, but that still wouldn't send the output to a file -- i.e. you still create the string then write that.

15:25 kotarak: ahh, ok, thanks.

15:25 kotarak: that's what I was wondering about.

15:27 How do pr or prn handle errors?

15:28 More specifically, is there a documented return value you're supposed to check, or are you supposed to rely on exceptions to report any errors?

15:29 i.e. if you need to be able to know for sure (or as sure as possible), whether or not something went wrong by the time you finish closing the file.

15:32 Chouser: pr and prn will return nil or throw an exception

15:32 Lau_of_DK: Do you guys generally use the java convention when naming clojure vars/functions ?

15:32 rlb: Lau_of_DK: I'm not sure what conventions you're talking about, but I know scheme and lisp much better than java, so I tend to treat clojure like a scheme/lisp.

15:33 Lau_of_DK: k

15:33 rlb: Chouser: thanks.

15:33 Chousuke: java convention?

15:33 Raynes: I remain closer to Scheme and such when naming vars and functions

15:35 rlb: Lau_of_DK: in particular, assuming that this relates to what you're asking, I would use names like open? exists? with-frob-connection, etc.

15:37 Lau_of_DK: I meant specifically like the java convention names everything with smallFirstCapitalizedAfterThat

15:37 * durka42 doesn't use camelCase in clojure

15:45 rlb: I'm fairly unfond of camelCase anywhere...

15:47 Raynes: It's very unlispy to use camelCase.

15:48 Lau_of_DK: It is -unfortunately I didnt notice until I had written about 4000 lines of it

15:48 rlb: Lau_of_DK: emacs to the rescue ;>

15:48 (or maybe perl)

15:49 Lau_of_DK: Emacs... :)

15:49 kotarak: Or Vim :)

15:49 * kotarak couldn't resist.

15:49 Raynes: Screw Vim.

15:49 Lau_of_DK: kotarak: neither could Raynes

15:49 Raynes: Agreed.

15:50 Lau_of_DK: ;)

15:50 rlb: That would be nice -- a tool that knows clojure well enough to unambiguously do a search/replace for a particular logical entity, i.e. "this particular foo".

15:56 leafw: rlb: yeah -- who is developing that?

15:58 Lau_of_DK: Java folk, I have a bunch of java files that I want to incorporate in my project, is there a quick way to convert them all to class files? java -compile * or something ?

15:59 kotarak: Lau_of_DK: Have a look in the clojure ant build.xml.

15:59 Should be easy to transfer.

15:59 Lau_of_DK: I was hoping for something quick and dirty :)

16:01 kotarak: Lau_of_DK: well. That's quick and clean. Isn't that better? :)

16:01 ayrnieu: find .|egrep 'java$'|xargs javac

16:02 Lau_of_DK: perfect :)

16:02 sorry Kota, Im too lazy to be clean

16:02 slashus2: Lau_of_DK: javac *.java

16:03 kotarak: Lau_of_DK: hm... That will come to haunt you anyway later on.... Be clean now, have less work later. ;)

16:04 leafw: Lau_of_DK: I use often: javac -classpath .$(find -name "*.jar" -printf "%h/%f:"):. $(find -name "*.java" -printf "%h/%f ")

16:05 or some variation.

16:05 Lau_of_DK: cool

16:07 blbrown: is OK to put lisp datastructures in a database. I have this idea for storing a list of items. hmm

16:07 RDBMS don't really support tree/list structures very well

16:13 hoeck: blbrown: well, that hurts the relational model very hard

16:13 blbrown: you use the ability to express queries over those stored lists

16:14 but for storing code, or big hashtables, maybe

16:16 blbrown: yea, would hurt the relational model. But modern databases are great for storing and retrieving "Data" and that would be the main goal.

16:16 For example, it would be better than storing XLM

16:16 XML

16:19 Lau_of_DK: hoeck: Did you ever get beyond that segfault?

16:20 hoeck: Lau_of_DK: not with sofiaba, the jme examples run fine, at least, they run

16:20 Lau_of_DK: ok - weird

16:22 hoeck: it seems they all require shaders, too much for my old chipset graphics

16:22 Lau_of_DK: Yea they're pretty advanced

16:23 hoeck: yeah, weird, before segfaulting they say something like "unsupported texture size - rescaling to power of 2"

16:23 Lau_of_DK: Hmm, if you comment out the call to makeTerrain, you should be fine, thats the only object I scale

16:23 hoeck: and that my card won't support textures other than with 2^n sizes

16:23 jhujhiti: (HttpServer/create (InetSocketAddress. 8080)) where create is a static method of HttpServer. what am i doing wrong? i get "No matching method: create"

16:24 Lau_of_DK: Its also about to go away, Im working on a much larger streamed in terrain

16:30 It seems the gentlemen who wrote these java-classes were working off some odd OS, which has characters that are unmappable for UTF8. Is there a quick-fix way to convert them ?

16:30 hiredman: well

16:31 magic

16:32 hoeck: blbrown: definitely better than storing xml

16:32 blbrown: hoeck, exactly

16:32 hoeck: blbrown: but you loose the expressive power of the relational algebra

16:33 some databases provide means to query graph-like structures in sql

16:33 or you use datalog for that

16:33 blbrown: blbrown, kind of buitin serialization if I save data as lisp code, plus, I suck at algebra. hehe.

16:33 Lau_of_DK: blbrown: Have you looked at Voldemort / CouchDB ?

16:33 hiredman: there are also graph databases

16:35 blbrown: Lau_of_DK, I looked at couchdb. for my application, it is for my irc bot, so it isn't a production system or anything. couchdb might work. Actually my databse I was going to use was sqlite

16:35 Lau_of_DK: Then go with Derby instead

16:35 If you go with some type of SQL program, check out ClojureQL

16:36 Im quite stuck here - Can someone help me compile this: http://mfkarpg.110mb.com/jme/TerrainPass-jME2.zip ?? Please

16:36 blbrown: Lau_of_DK, why did you recommend couchdb. At the same time, I want to try new things

16:37 Lau_of_DK: I recently read an article about a new website called Urbantastic.something which used Clojure and CouchDB and were quite happy with that choise

16:37 twopoint718: CouchDB is a key/value store, right?

16:38 Lau_of_DK: As far as I understood, yes

16:38 twopoint718: So can you do things like give me all of X whose value is Y?

16:38 Lau_of_DK: Google will tell you :)

16:38 blbrown: I thought it was a document database

16:39 twopoint718: say: SELECT * FROM some_table WHERE id==10

16:39 Lau_of_DK: But actually, Clojure comes pretty close to perfect, if you want to write your own database system

16:39 blbrown: yea, that won't take any time, hehe. Actually I like the idea of serializing objects as a database system

16:39 hiredman: (use terracotta and persist to disk)

16:40 twopoint718: Heck for most of what I do (usually just store little config files) I love being able to 'print' 'read'-able data structures to a flat text file.

16:40 hoeck: twopoint718: yeah, thats a big win for lisps in general

16:40 hiredman: clojurebot keeps factoids in a hash map printed to a file

16:41 blbrown: OK, here is what I think I will use, order of preference: couchdb -> terracota -> derby/hsqldb -> serialize -> rabbitmq -> sqlite

16:42 hiredman: terracota will, I think, be the most work there

16:42 twopoint718: I was just looking to see what the equivalent was in Clojure and was happy to find (read-string (slurp "datafile.clj"))

16:43 blbrown: hiredman, yea, deployment on win32/linux would have to be easy. derby or hsqldb sure is a simple approach though, hmm

16:51 great, on your own personal projects, you can make architecture decisions in 5 minutes.

16:54 rlb: If clojure doesn't already have it, it might be interesting to have a persistent object store like rscheme's.

16:56 -- the ability to make a data structure and everything it references (at least read/writable things) persistent automatically, and only fault it in/out on demand as the pointers are traversed.

16:57 ...same thing the Texas persistent object store does (one of Dr. Wilson's topics)...

16:59 In any case, it might be interesting to at least have something like a "giant seq" interface, i.e. easy to use list/vector/hash-table's for data that's way to big to fit in RAM.

17:01 hiredman: rlb: lazy-seq

17:01 just don't hang on to the head

17:03 rlb: hiredman: I wonder if some of the semantics that I was thinking of don't fit in well with a functional model (unless you use some kind of versioned store), i.e. a giant vector (32GB?), that you can read and write efficiently, but that can be treated like a seq.

17:04 hiredman: well

17:04 rlb: hiredman: of course I'm still getting used to clojure, so I'm not familiar enough to have any strong opinions/ideas about it.

17:04 hiredman: functional implies no write

17:04 rlb: s/it\./it yet./

17:04 hiredman: right -- that's what I meant.

17:07 Perhaps you could have a store that handled things more like clojure does internally, i.e. just create types of vectors, lists, etc. that can handle using the disk as a backing store, but still preserve the right functional semantics.

17:08 anyway... not today's problem.

17:12 Do any filesystems allow the user to efficiently and atomically splice two files?

17:12 (just curious)

17:22 Does clojure have anything like atexit or trap? i.e. a way to register a function to be run when the program exits?

17:23 (actually dynamic-wind or unwind-protect would be just fine here -- I'll go check for that...)

17:24 kotarak: rlb: (try ... (finally (do-something)))

17:25 rlb: kotarak: ahh, thanks -- I suppose I should have thought of "finally".

17:25 (or rather expected finally)

17:26 kotarak: rlb: since there are no continuations, try-finally should be sufficient, I guess.

17:26 rlb: kotarak: right.

17:28 kotarak: rlb: beware of lazy-seqs so. (try (map #(do-something-depending-on-the-finally %) some-seq) (finally (close-some-file-or-whatever))) will get you in trouble.

17:28 rlb: kotarak: do you know if try will even handle catchable signals?

17:28 kotarak: s/so/though/

17:28 rlb: signals in the sense "kill -15 1234" ?

17:28 rlb: kotarak: right -- signals that you can catch, but that take the app down by default.

17:29 i.e. stuff you would protect with a bash trap.

17:29 kotarak: rlb: dunno. Probably some JVM setting somewhere.

17:29 rlb: The goal is to make sure that the program always cleans up on exit if it didn't finish cleanly.

17:29 (if that's possible, i.e. no kill -9)

17:29 jhujhiti: http://blog.webinf.info/2008/08/intercepting-sigterm.html

17:30 i only googled that for you because i was curious of how to do it myself

17:30 rlb: jhujhiti: thanks.

17:31 kotarak: what did you mean wrt lazy-seqs?

17:32 kotarak: just that the finally could/would be executed before the list was fully traversed?

17:33 kotarak: rlb: if you use resources like a open file in something like map or the like you need to realize the sequence before leaking it outside the try. Otherwise the file will be already closed when the seq is realized.

17:33 rlb: kotarak: right -- that's what I guessed you meant.

17:33 kotarak: rlb: yes. one can do (doall (map ...)) to realize the seq.

17:33 rlb: kotarak: right.

18:00 clojurebot: svn rev 1316; made futures use CachedThreadPool

18:04 pietia: hello

18:04 anyone use eclipse + clojure plugin ?

18:05 clojurebot: svn rev 1317; made letfn emit fn, not fn*

18:06 pietia: clojurebot, hello darling :P

18:10 rlb: Just started reading about clojure's answer to objects. It looks nice so far -- more like clos/generic-functions...

18:12 ayrnieu: rlb - defmulti/defmethod , you mean?

18:14 blbrown: rlb is that on a blog somewhere

18:15 Raynes: pietia: I have.

18:15 pietia: Raynes, do you have problems with running scripts?

18:16 rlb: ayrnieu, blbrown: I was just poking around here -- http://clojure.org/multimethods

18:17 Hmm, for now perhaps I'll just rely on File atomic creation, and not worry about other (non-java) clients.

18:17 Raynes: pietia: Running doesn't run a script, it just loads the REPL, you can then load the script with C-M-l I believe and use it like that. With no offense to Laurent, I know he's doing the best he can, the Eclipse plugin leaves a lot to be desired such as autoindent. I recommend using the netbeans plugin simply because I find it suited to everyday editing and development.

18:17 blbrown: I have a good zazzle clojure t-shirt idea. "Clojure, I can finally be productive again"

18:18 pietia: Raynes, yeah, it loads REPL - that's the point ;)

18:18 Raynes: Someone really needs to make a damned wall paper.

18:20 I would give all the parentheses in the world for a Clojure wall paper :<. I suck at image editing.

18:26 blbrown: Raynes you might post something about the google group board, I wouldn't mind one either.

18:42 brennanc: been learning Clojure for the last 2 days. It's my first lisp dialect. It's very impressive. Anybody using it on their servers? Wondering easy it is to get sites up and running with it.

18:43 how is it deployed normally?

18:45 dcnstrct: Does Clojure have any 'lispy' file IO functions?

18:45 something like with-open-file

18:46 brennanc: yes, it has with-open

18:46 dcnstrct: or does everyone just use java.io ?

18:46 ahh

18:46 ok I'll check out with-open

18:47 gnuvince_: dcnstrct: there's also some nice stuff in clojure.contrib.duck-streams

18:47 dcnstrct: good to know, will check that

18:52 powr-toc: brennanc: If you're talking webapps, it's easily deployed in standard java infastructure... i.e. an app server/servlet-container... for non web stuff, you just throw a jar on the java classpath... easy! :-)

18:53 brennanc: like glassfish? I've only glanced at java app servers. only looked at them briefly.

18:53 powr-toc: brennanc: yeah, glassfish, jetty, tomcat, jboss... any of 'em

18:54 brennanc: cool, I'll look for that once I get through the "Programming Clojure" book

18:56 powr-toc: Chouser: looks like add-watch's has changed again... did you revise your code yet?

19:00 lethalcode: Howdy folks - Is there a way to get a pared down version of clojure for already compiled .cljs to link to? No compiler, interpreter, etc.

19:00 hiredman: mm

19:01 clojure doesn't have an interpreter

19:01 lethalcode: By that, I meant Repl :D.

19:02 brennanc: you can compile to a .class file. From there you can run it like any other java class file. You will need to have clojure.jar and whatever other libraries you need though. Not sure if that answers your question.

19:02 dcnstrct: lol @ spit and slurp functions awesome naming

19:03 lethalcode: Not really, brennanc - clojure.jar also includes the Compiler, Repl, etc.

19:03 durka42: hiredman: what is clojure-slim.jar?

19:03 lethalcode: What I want is to build .class files from .clj, then jar it up (aimed at an embedded platform with minimal resources)

19:04 So I don't need Repl, Compile, etc.

19:04 brennanc: lethalcode: ahh, I think I get what you are asking. I'm only on my 2nd day of learning Clojure but you might be able to re-jar it without those things in there. Hack it down so to speak.

19:04 durka42: the thing is, you might need those things, to implement the read and eval functions for instance

19:05 brennanc: not sure about the dependencies

19:05 durka42: lisp has trouble separating these things :)

19:05 lethalcode: brennanc: Trying to do that now. Removed them, hacked at RT.java, etc.

19:05 durka42: We don't want read and eval. =).

19:05 We're using clojure to develop an app for users. Won't include eval() or any lisp scripting by the user, etc.

19:07 durka42: well, i know there's been work done on getting clojure running in places where you can't generate code, like applets and android

19:07 so it might be possible

19:07 lethalcode: durka42: Any idea who those folks are?

19:08 durka42: well, rhickey for one, of course

19:08 hiredman: lethalcode: why do you need to remove eval completely? why not just don't use it?

19:08 durka42: i'd advise looking through the mailing list for android

19:08 hiredman: I don't think the android stuff removes eval, it just doesn't work if you try to use it

19:09 lethalcode: hiredman: Long story. What we're actually doing is compiling clojure to .class files. Then using xmlvm to turn .class files into .objc files.

19:09 So we can then compile for the iPhone. :D.

19:09 durka42: that sounds a lot like what you have to do for android

19:09 hiredman: long story indeed

19:09 lethalcode: However - xmlvm has limited support. Can't do too much more than a "Hello World".

19:10 hiredman: yeah, track down the android stuff, I think there was a patch

19:10 that could be tricky

19:10 xmlvm looks twisted

19:10 lethalcode: I'm hoping that by removing eval and compile, we can reduce the work needed on xmlvm by a considerable amount. (Reflection, etc?)

19:11 The work needed to write wrappers in .objc, rather.

19:11 durka42: actually, xmlvm claims it can compile from android to iphone

19:11 lethalcode: durka42: Not quite true. :D.

19:11 durka42: i suspected :p

19:11 lethalcode: durka42: A Hello World is the only thing they can handle.

19:12 And they implemented just barely enough of the android API for that hello world.

19:12 (And often incorrectly. e.g: ImageView uses hardcoded image names . . .)

19:13 As for Android: Davlik VM has cut out some portions needed for dynamic code generation as well, it's true.

19:13 But still has all the java files there that need to be wrapped when converted to objc.

19:13 brennanc: xmlvm looks wicked. I'm looking at the javascript target now. That could be fun...

19:14 lethalcode: After converting clojure .classes to objc, we have *90* java header files that aren't implemented in xmlvm's compatability layer. 49 of those are Error or Exception classes. A bunch of others are probably easy to wrap, just need doing. And then there's Reflect, ClassLoader, Thread, . . .

19:15 I've been talking with Arno (main author of xmlvm) about what needs to be done and can be done.

19:15 durka42: Thread is kind of important...

19:16 lethalcode: Right. I intend to either ask Arno to do it (if he's willing), or to implement it myself. (Objc tutorials, here I come?)

19:16 Reflect and ClassLoader, though - If they can be done away with, that's probably best?

19:16 Raynes: blbrown: Good idea, I'll get right on that

19:39 Chouser: powr-toc: http://gist.github.com/32494 should be up to date

19:46 powr-toc: Chouser: cool :-)

19:47 cmvkk: I frequently get in these situations where I essentially want a constant but I have to 'initialize' it first.

19:47 and it always seems wasteful to me to use a ref for something that i'm only planning to change the value of once

19:48 but there's not actually any other way right?

19:48 rhickey: cmvkk: atom is the most lightweight

19:56 brennanc: is it considered bad practice to do "(def my-func #(do-something %))" instead of "(defn my-func [x] (do-something x))"?

19:57 hiredman: I think it is

19:57 Chouser: it's not idiomatic

19:57 you won't get docstring and arglists in the metadata

19:57 hiredman: at the very least I would prefer using (fn ) to #( ) in that case

19:57 cmvkk: it seems like you're only saving about 4 characters too.

19:58 brennanc: k, thanks

20:00 hiredman: ,((partial apply identity) 1)

20:00 clojurebot: java.lang.IllegalArgumentException: Don't know how to create ISeq from: Integer

20:00 hiredman: I see

20:02 brennanc: I'm looking at this code in the clojure book: (defn non-blank? [line] (if (re-find #"\S" line) true false))

20:02 why is the if needed? and isn't there a better way if it is needed than explictly saying true false?

20:03 ayrnieu: brennanc - it could equivalently say (not (not (re-find ...))) ; would that be better?

20:03 Chouser: (boolean (re-find ...))

20:04 cmvkk: does re-find return nil if it doesn't find anything?

20:04 hiredman: ,(re-find #"\S" "")

20:04 clojurebot: nil

20:04 hiredman: ,(re-find #"\S" "foo")

20:04 clojurebot: "f"

20:04 hiredman: ,(re-find #"\S" " ")

20:04 clojurebot: nil

20:04 brennanc: yes, that was what I was looking for

20:04 anything that is not false or nil evaluates to true, correct?

20:04 cmvkk: so if you take the 'if' out, it will function the same as a predicate but you can also use it for if-let and stuff.

20:05 hiredman: correct

20:05 brennanc: so why would it be needed to actually cast it to a boolean

20:05 hiredman: *shrug*

20:05 cmvkk: heh

20:05 actually i guess it doesn't matter; the true value would probably be pretty useless

20:06 ayrnieu: the author was being fastidious. This is like having a side-effecting function carefully not return anything of interest.

20:38 lethalcode: Trying to compile clojure/core_print.clj gets this error: Exception in thread "main" java.lang.Exception: namespace 'clojure.core_print' not found after loading '/clojure/core_print'

20:38 Compiling clojure.core works fine, but clojure.core_print (or any other file that uses in-ns and is in a namespace that doesn't match its filename) borks.

20:39 Any easy fix?

20:41 hiredman: lethalcode: I believe compiling clojure.core should take care of core_print

20:41 the file core-print is loaded using load-file by clojure.core

20:42 (isn't it?)

20:42 Chouser: I believe that is correct.

20:42 rhickey: hiredman: right, you can only compile namespaces, core-print is not a namespace

20:43 lethalcode: Really? Because, e.g, print-sequential, print-meta, print-method, etc - aren't being turned into classes.

20:45 rhickey: core-print is a subsidiary of core and gets compiled when core does

20:45 lethalcode: Then shouldn't it be generating files such as clojure/core$print-method__blah.class ?

20:49 Chouser: classes/clojure/core$print_sequential__5231.class

20:49 rhickey: print-method is a multimethod, won't have a class, I don't understand the question - if you build clojure it compiles core - can you not build?

20:51 cp2: 'sup rhickey

20:54 lethalcode: Let me back up a bit. rhickey, don't know if you saw my earlier comments/statements - I'm building a more minimal clojure, targeting XMLVM (which will convert .class files to objective-C for iPhone development)

20:55 rhickey: lethalcode: scary

20:55 lethalcode: So to do this, I've set up a smaller compile environment for clojure.

20:55 Got most of the jvm classes pared down, I think, but clojure/core.clj at least seems to be needed.

20:56 So I've got the clojure core .clj files in the project, and am compiling them using the (full, unabridged) clojure compiler.

20:56 And dumping .class files into build/classes. There are build/classes/clojure/core$*.class from core.clj, but nothing that I can see from core_print.clj

20:57 rlb: Are the java string methods the normal way to manipulate strings (substrings, etc.)?

20:58 nevermind.

21:00 rhickey: lethalcode: I ant clean, mkdir classes, java -cp ./src:./classes:clojure.jar clojure.main, (compile 'clojure.core)

21:01 I get core$print*

21:03 lethalcode: rhickey: I'm using clojure.lang.Compile

21:04 And the only print functions I get are print, print_doc, print_namespace_doc, print_special_doc, print_str, printf, println, println_str

21:05 rhickey: lethalcode: use clojure.core/compile

21:07 gnuvince_: (doc compile)

21:07 clojurebot: Compiles the namespace named by the symbol lib into a set of classfiles. The source for the lib must be in a proper classpath-relative directory. The output files will go into the directory specified by *compile-path*, and that directory too must be in the classpath.; arglists ([lib])

21:10 lethalcode: (+ 2 2)

21:10 clojurebot: 4

21:10 lethalcode: Cool.

21:10 rhickey: As in, use Repl then (compile 'filename) instead of using clojure.lang.Compile? How do they differ?

21:10 (doc clojure.lang.Compile)

21:10 clojurebot: excusez-moi

21:11 lethalcode: (. @"hello" substring 3)

21:15 hiredman: lethalcode: compile takes a namespace

21:16 not a filename

21:16 Chouser: ,(.substring "hello" 3)

21:16 clojurebot: "lo"

21:16 hiredman: the unit of compilation is by namespace

21:17 lethalcode: (. "hello" substring 3)

21:17 Hm.

21:17 hiredman: And the unit of compilation for java.lang.Compile is file, not namespace?

21:20 hiredman: uh

21:20 you must mean clojure.lang.Compile

21:20 banisterfiend: some guy just said this about clojure, is it true? "banisterfiend, I haven't used it, but I heard its implementation is full of black magic and dark and sinister hackery."

21:20 hiredman: and that I dunno, my guess would be that it is namespace as well

21:21 ayrnieu: banister - it certainly doesn't seem that way, but you can look at it yourself.

21:21 lethalcode: hiredman: Err, yeah.

21:21 hiredman: the java source takes some getting used to, but the clojure source is very readable

21:25 Chouser: banisterfiend: nah. other than STM, it's pretty straightforward, though frequently clever.

21:26 in my opinion it's more the design than the implementation that's the key

21:26 though the STM is still magic to me. :-)

Logging service provided by n01se.net