#clojure log - Dec 17 2008

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

0:05 bradbev: are def's evaluated at compile time when AOT compilation is used?

0:06 I think they are, because one of my defs is (def foo (JFrame. "foo")), and when compiling using ant I get problems because Swing can't be found

0:10 Chouser: everything gets evaluated when you compile -- it's just like a normal run, except generated class files are saved out along the way.

0:11 bradbev: so how does that actually work if I construct Java objects in defs - how do they get saved?

0:12 hiredman: they don't

0:12 Chouser: oh, good, because I didn't know.

0:12 hiredman: the code to generate them gets compiled and then new ones are made when the compiled code gets run?

0:13 hiredman: yeah

0:13 mean, it must right?

0:13 the other way is just crazy

0:13 bradbev: which also means that at compile time the defs need to be able to execute

0:13 my use-case is that I have a hash-map to describe a gui & a couple of functions to load/show it

0:13 hiredman: bradbev: there is some var that is set at compile time you can (if ) around

0:13 bradbev: I construct the Swing objects in the def

0:16 dhaya: this seems relevant http://groups.google.com/group/clojure/msg/169922392f950839 (the note above print duping them and reading back later). So it does look like they get saved after all?

0:17 hiredman: but rhickey did not go through and add print-dup ability to all java objects

0:17 clojurebot: rhickey?

0:17 clojurebot: he works hard so you don't have to

0:18 bradbev: hmm, I'm not sure that's the same thing at all

0:18 hiredman: print-dup is for clojure data structures I think, because certain clojure data structures can have different underlying impls

0:18 bradbev: if the def was not evaluated at AOT, but was evaluated at load then I'd be fine

0:19 dhaya: There is a *compile-files* flag that you can use to prevent evaluation during AOT compilation.

0:20 hiredman: bradbev: *compile-files* is true when you are compiling

0:20 bradbev: OK

0:20 hiredman: (def a (when-not *compile-files* (my-big-init)))

0:21 dhaya: beat me

0:21 bradbev: now, the other thing that is screwy is (defn frame (JFrame. "foo")) also causes ant to break during compile

0:21 that should be lazy evaled, right?

0:21 hiredman: uh

0:21 no

0:21 oh

0:21 defn not def

0:21 bradbev: oh, crap - how did that even compile though?

0:21 hiredman: *shrug*

0:22 well it did nae compile did it?

0:22 bradbev: heh, true

0:23 ok, converting from a def to a defn & a call fixes the issue

0:24 though it does leave the problem that defs are evaled at compile time & they may construct java objects

0:26 hiredman: that is what *compile-files* is for

0:27 compile and load are kind of the same thing, compile just also outputs class files

0:27 bradbev: yeah, wrapping the def in (if (not *compile-files*)) works

0:28 thanks for the help

0:28 dhaya: bradbev: (when-not might more idiomatic i think..

0:29 bradbev: dhaya: thanks - I didn't know about that (I did know unless isn't there :))

0:30 dhaya: I have no idea about unless. is that a CL thing?

0:31 hiredman: ruby has it

0:31 dhaya: ah..ok.

0:32 bradbev: CL has it also

1:06 wipewindows: which should I ask for as a christmas prsent, im a strange loop or GED?

1:11 cads: wipewindows, I'd just download some of godel's papers, buy some escher prints, and enjoy some pirated bach

1:13 it's a lot of dumbed down philosophy and the author tries to get across how wonderful and strange our consciousness (his consciousness) is

2:48 dmiles: any DotLisp hackers in here atm?

2:50 trying to figure out where (Hex/DecodeHexString text) comes from

4:11 AWizzArd: clojurebot: max people

4:11 clojurebot: max people is 116

10:22 rhickey: any contrib-ers out there? move to gc go ok?

10:24 Chousuke: is everything in contrib EPL now?

10:32 rhickey: Chousuke: yes

10:55 RSchulz: I just checked it out and built it without a hitch.

10:57 AWizzArd: rhickey: what again was the title of this book about concurrency in Java?

10:57 rhickey: Java Concurrency in Practice

10:57 AWizzArd: thx

10:58 * duck1123 is reading it right now

10:58 duck1123: reading chapter 6.2.5

10:59 gnuvince: Wouldn't that be a section of chapter 6?

10:59 </anal>

11:08 kyleburton: /?

11:08 er, does there happen to be a way to know the name of the form being defined?

11:09 * Chouser predicts general failure of rule-following regarding the issue tracker.

11:09 rhickey: kyleburton: for what to know?

11:09 kyleburton: well, I was toying with creating a log form

11:09 and it'd be nice to know the file name (if available), line number and fn name

11:09 rhickey: Chouser: what's the alternative?

11:09 kyleburton: so it could expand to including that in the log stmt

11:09 eg: (defn some-func [] (log-debug "foo"))

11:10 it'd be nice if that could expand into something like:

11:10 (defn some-func [] (log/log-debug "test.clj" 107 "some-func" "foo"))

11:10 wlr_: google code's clojure-contrib still has svn/trunk/CPL.txt

11:11 kyleburton: well, really w/the args wraped in a lambda so they dont get computed unless the levle is that high

11:11 kind of like __pretty_function__, __LINE__ and __FILE__

11:11 well, exactly like those

11:12 Chouser: rhickey: I don't suppose there's any way to display those rules on the "new issue" form?

11:13 duck1123: Chouser: where are these rules?

11:13 Chouser: duck1123: exactly.

11:14 rhickey: Chouser: I can pre-fill the description box with text, some of the rules are there

11:15 Chouser: ok. I don't have a good alternative. Maybe some firm policing will be sufficient.

11:16 duck1123: rules: http://groups.google.com/group/clojure/browse_thread/thread/1a4fe97a957ec52a

11:18 rhickey: Chouser: ok, full set of rules now in the entry form

11:19 duck1123: now that the issue tracker is being used, should clojurebot announce new tickets?

11:19 Chouser: kyleburton: (defmacro log [msg] `(prn ~msg ~*file*))

11:20 rhickey: duck1123: there is a dev feed, just trying to get it set up the way I want

11:20 kyleburton: ok, *file* is good, is there a *line* and perhaps a *top-level-form-name*?

11:20 Chouser: kyleburton: looks like there's currently no similar way to get to the line number.

11:20 kyleburton: Chouser: thank you re: *file*

11:20 Chouser: kyleburton: but both are available as metadata of the var -- 'some-func' in your example.

11:21 kyleburton: Chouser: yes, but how can you get the name of the enclosing top level form so the macro can see it?

11:21 Chouser: ...but I don't think the name of that var is available to the expression being evaluated for the var's value.

11:21 rhickey: Chouser: *file* isn't going to help there, as it's value at runtime will be nil

11:21 kyleburton: rhickey: even if you expand with ~*file*?

11:22 rhickey: i.e. a macro can use it, but to emit it doesn't help

11:22 kyleburton: rhickey: doens't that get resolved at compile...

11:22 Chouser: rhickey: sure, but in that macro I posted the compile-time value of *file* is inserted into the expression

11:22 rhickey: that's all this is for? nevermind

11:22 gnuvince: Does Java allow mutating final fields?

11:23 Chouser: gnuvince: don't think so. I think that's the point of them being final.

11:24 AWizzArd: I think Clojure declares a lot of stuff as final under the hood, to come to its performance.

11:25 gnuvince: Chouser: I wasn't sure what final meant for fields.

11:32 RSchulz: A final field in Java cannot be assigned, but the object to which it refers (if it's not primitive) but nothing prevents invoking mutating methods on the instance referred to by that field.

11:32 It's not at all like C++ const.

11:32 Oops. That came out mangled.

11:32 Chousuke: it's more like a const*

11:33 or is that *const? :P

11:33 RSchulz: You can't reassing a final field after initialization, which must happen by the time the constructors exit.

11:33 But you can call any method on the values in such fields.

11:33 Chousuke: Yes, it's like *const.

11:44 aperotte: Chouser: I figured out why I was getting different behavior when using (load-file ...) versus evaluating each form in the file

11:45 Chouser: I traced it down to a function definition that used map, but was being used for side effects and the return value of the function wasn't being used for anything

11:46 Chouser: I'm assuming that the map was evaluated lazily (?) when using (load-file) because it didn't need to print the result whereas at the repl it was forced because of the need to print (?)

11:50 Chouser: aperotte: ah, very good!

11:50 thanks for bringing me up-to-date. That's likely to come up again.

11:51 aperotte: No problem, thanks for the help

11:51 RSchultz: Thanks for your help in trying to figure this out as well.

11:57 Lau_of_DK: Good evening all

12:00 ericthorsen: I have a clojure resource in a netbeans module that is calling (clojure.core/require "a.properly.placed.namespace.file") which is referencing public java classes in the same module. The clojure file gets loaded but cannot see the java classes. Anyone have any insight as to how I might trouble shoot this?

12:02 rhickey: the require is for a .clj file? not compiled?

12:02 ericthorsen: rhickey: yes

12:03 rhickey: ericthorsen: you might have a much easier time if you compiled it

12:04 it's probably related to classloader that loaded Clojure doesn't have access to that module?

12:06 ericthorsen: rhickey: yes...we are going down that path as well.

12:07 rhickey: ericthorsen: AOT is motivated in part by trying to remove issues related to fancy classloader hierarchies like NB and dynamic classloading, by getting rid of the latter.

12:25 http://groups.google.com/group/clojure-dev - read-only via web/xml, will get all issue changes for clojure and contrib

12:32 hrm, wiki edits go in svn revision stream...

12:34 RSchulz: aperotte: Sorry I missed that before. I'm glad you sorted out the problem. And thanks for letting us know what it was. It's something to keep in mind.

12:35 ffailla: I are trying to run the clojure.lang.Compile command from a command line, how do i export the clojure.compile.path system property on a bash shell

12:59 tomhickey: rhickey: i see the wiki edits in the revision list on the site, but not in my svn client

13:00 rhickey: tomhickey: you're probably just pulling trunk - the wiki is a sibling of trunk, not under it

13:01 tomhickey: rhickey: ah, i see

13:32 * rhickey seems to have scared everyone away from the issue tracker

13:32 Chouser: success!

13:33 rhickey: Not really, as I need patches/bug-reports to go there, getting lost in group traffic

13:33 Lau_of_DK: Rich, it looks good, not scared :)

13:36 RSchulz: rhickey: You asked us to discuss issues on the list before submitting issues, which of course makes complete sense. If an question doesn't come to resolution there, is it reasonable to submit an issue?

13:36 Case in point: How to get (shutdown-agents) to work without explicitly calling it. The list thread didn't end up with a resolution.

13:37 rhickey: RSchulz: probably not, we should be able to resolve bug or desirable feature on the group

13:37 As far as that one, I don't see why clojure should do something specific, you have shutdown-agents

13:37 kotarak: RSchulz: maybe the Repl could be modified to allow shutdown-hooks?

13:38 rhickey: but in any case, the issues list is not for advocacy

13:38 RSchulz: I'm not asking for Clojure to do something, but there's a gap right now. There was the idea to use daemon threads for agents, though.

13:41 rhickey: RSchulz: then people who set off their whole program to run in agents will complain their agent threads die, and why do they have to explicitly wait for them

13:43 kotarak: When the Repl receives the ^D it reads eof and stops. Maybe one can install some shutdown hooks, which are executed after the eof is received.

13:43 RSchulz: How would one create generic facilities that use agents behind the scenes without burdening the user of those facilitiees to use (shutdown-agents) before exiting?

13:43 rhickey: I don't understand what you're saying. My specific problem is that calling (shutdown-agents) in a JVM shutdown hook seems not to be working.

13:44 Chouser: RSchulz: when to shutdown background threads is an application-wide question, not something that can be answered in smaller pieces, it seems to me.

13:44 RSchulz: Right. And I'd like to make it work in a generic way: via JVM shutdown hooks. That seems eminently reasonable to me.

13:45 Chouser: RSchulz: what makes you think the JVM shutdown hooks will run before all the threads have quit?

13:45 rhickey: RSchulz: this is a pure Java problem - the agents just use the Executors framework

13:45 RSchulz: Eh? I want it to run as part of the JVM shutdown processing. That's what they're for, right?

13:45 rhickey: RSchulz: shutdown happens after all threads are done

13:46 RSchulz: So what's the problem? Why do I hang upon CTRL-D from the REPL unless I call (shutdown-agents) _from_ the REPL?

13:46 So it's a chicken-and-egg thing?

13:46 rhickey: ctrl-d works for me

13:46 RSchulz: rhickey: When you've started agents?

13:46 walters: the threads have to be daemon threads (see Thread.setDaemon)

13:46 RSchulz: Agents that _have_ been (await ...) -ed?

13:47 rhickey: RSchulz: there-s your problem - your awaiting and not geting your ctrl-d

13:47 RSchulz: Eh?

13:47 Every agent I start gets awaited. Then later on when I CTRL-D, it hangs.

13:47 rhickey: you're blocked in await and don't see eof

13:48 RSchulz: I'm _not_ blocked in await. It returns. Otherwise I wouldnt' get the next REPL prompt.

13:48 I can do much stuff after returning from await and then when I CTRL-D, it hangs.

13:49 rhickey: RSchulz: please write a small example program that demonstrates your problem. Debugging english descriptions is impossible

13:49 RSchulz: And do what with it?

13:49 Send it to the list?

13:49 The reason I'm here now is that that thread on the list didn't get any resolution...

13:50 rhickey: yeah, or paste here. You're saying you have a problem - help us replicate it. You didn't post code there either.

13:51 can't replicate, can;t fix. Giving a verbal description puts the onus on others to write a test case to reproduce the problem

13:51 Chouser: RSchulz: is this clojure.lang.Repl, or some other Repl?

13:51 RSchulz: The Contrib REPL.

13:52 Chouser: clojure.lang.Repl does a System/exit after ^D, which doesn't hang on the agent pools.

13:55 AWizzArd: Can I find out the path in which my program was run? If yes, how?

14:00 Lau_of_DK: Onus.... :)

14:01 rhickey: Chouser: I wonder if this unifying patch still does that? http://groups.google.com/group/clojure/browse_frm/thread/2aeb7bdc789d5933#

14:02 RSchulz: OK. There it is (on the list).

14:04 Chouser: rhickey: that patch appears to remove the System/exit and not re-instate it anywhere. I'm not in a position to test it directly right now.

14:05 I've got completely hangled classloaders at the moment.

14:05 mangled

14:23 AWizzArd: Is there something like read-line for files, which returns a vector of strings (of the lines of that file)?

14:23 Chouser: (doc line-seq)

14:23 clojurebot: Returns the lines of text from rdr as a lazy sequence of strings. rdr must implement java.io.BufferedReader.; arglists ([rdr])

14:23 kotarak: There is line-seq.

14:24 AWizzArd: Okay, so that is a bit closer to what I meant, thanks

14:25 omg, I just saw http://www.roseindia.net/java/beginners/java-read-file-line-by-line.shtml

14:25 why not just say (map function (lines "myfile.txt")) ?

14:26 4x new in that file, uh!!

14:26 "new"

14:26 Chouser: to be fair, a couple of those are still needed with line-seq

14:27 only with duck-streams to we start to rise above

14:27 walters: that DataInputStream is unnecessary, you only need FileReader and BufferedReader

14:28 (i'm not defending the bewildering lack of File.open() in the JDK, but it's not quite that bad)

14:30 AWizzArd: I think the easiest really is to use the ds/reader + line-seq.

14:30 But ds/reader is not lazy, right? So it will read the whole file, may it be 50 bytes or 3 GB, yes?

14:34 Chouser: no, ds/reader just creates an appropriate java.io object, it doesn't actually read anything.

14:35 AWizzArd: okay, and line-seq itself is lazy

14:35 so if I just want the first 100 lines out of 21 millions it would take +/- as much time as if the file would only have these first 100 lines.

14:37 rhickey: Chouser: nice post to code with line number in google code!

14:37 very useful

14:38 Chouser: I've been wanting to do that, but sf.net was just too slow to be useful.

14:39 the rev number is in there too, so reading that thread a few weeks from now it should still make sense.

14:39 rhickey: saw that, very nice

14:42 code browsing seems very peppy

14:45 Lau_of_DK: rhickey: That "issue tracker" doesnt really seem to be the right tool for the job ?

14:46 rhickey: Lau_of_DK: how so?

14:46 RSchulz: Is there a way to get GC to colorize .clj files?

14:46 Lau_of_DK: rhickey: It doesnt provide a very good overview I think. And when reading on "pretty printing" for instance, next to no info is providing in the underlying 3 links.

14:47 kotarak: At least the template chooser could be more prominent. (And also marked as necessary for the type of issue)

14:58 hiredman: so clojure svn is in google code now?

14:58 Chouser: hiredman: yes

14:58 hiredman: clojurebot: svn is svn checkout http://clojure.googlecode.com/svn/trunk/ clojure-read-only

14:58 clojurebot: You don't have to tell me twice.

14:59 Lau_of_DK: Chouser: Have we switched away from Sourceforge to Googlecode?

14:59 Chouser: yes

14:59 Lau_of_DK: For what reason ?

15:00 hiredman: sf is :(

15:00 Chouser: more features, better response time

15:01 danm_: google code sure is faster

15:02 Lau_of_DK: Chouser: Am I to understand that we yet again missed a golden opportunity to switch to Git ? :)

15:02 Chouser: nope. switching to git is still a dead subject (imo) until Rich brings it up.

15:03 Lau_of_DK: Chouser: k

15:04 hiredman: clojurebot: relocate is svn switch --relocate file:/$PWD http://clojure.googlecode.com/svn/

15:04 clojurebot: c'est bon!

15:04 jimm: The download link on clojure.org still points to Subversion. Is that intended?

15:05 Chouser: that's the only place to get a .zip for now, I think.

15:05 rhickey: jimm: that's where the download is until the next release

15:05 jimm: rhickey: thank you

15:05 I see, the SVN link has been updated to google code

15:06 hiredman: svn rev 1162

15:07 clojurebot: svn rev 1162; EPL in header

15:07 svn rev 1168; Edited wiki page through web user interface.

15:07 svn rev 1169; Edited wiki page through web user interface.

15:07 svn rev 1170; Edited wiki page through web user interface.

15:07 svn rev 1171; Edited wiki page through web user interface.

15:07 svn rev 1172; Edited wiki page through web user interface.

15:07 hiredman: eeep

15:09 rhickey: I'll start putting comments on wiki edits since they're going in svn

15:11 hiredman: maybe I should filter wiki edits out?

15:12 Chouser: hiredman: it might be a bit noisy for a couple days, but I wouldn't be surprised if we appreciate the notification after a week or so

15:13 that's very interesting, though -- the wiki is stored in the projects own svn repo.

15:13 hiredman: it's cute

15:14 gah, that svn relocate deal doesn't really work

15:17 clojurebot: svn rev 1168; Edited wiki page through web user interface.

15:17 svn rev 1169; Edited wiki page through web user interface.

15:17 svn rev 1170; Edited wiki page through web user interface.

15:17 svn rev 1171; Edited wiki page through web user interface.

15:17 svn rev 1172; Edited wiki page through web user interface.

15:17 hiredman: clojurebot: stop that

15:17 clojurebot: I don't understand.

15:38 holmak: Apparently it is not acceptable to use the #() anonymous function form inside (-> ...) -- is this expected?

15:38 kotarak: holmak: you have to take care (-> x (#(do-something %)))

15:39 holmak: ah

15:39 Chouser: hm.

15:39 holmak: I guess -> was interacting poorly with the #() macro.

15:40 Chouser: indeed, the item to the left of #() is used as the name of the anonymous function

15:40 holmak: I thought since #(...) makes a function, -> ought to treat it as a non-list, and turn it into (#(...) arg)

15:40 That's obviously not what happens, given the macro expansions

15:42 Chouser: (-> foo #(+ % 2) (apply [3])) ==> 5

15:42 -> is easy to abuse.

15:42 holmak: I will use caution, then.

15:42 Chouser: (-> [i 3] (dotimes (prn i)))

15:42 hiredman: cute

15:43 holmak: You're making it look downright dangerous

15:43 "-> considered harmful"

15:43 kotarak: bah, -> is cool. :)

15:43 Chouser: well, just don't use it in circumstances where it makes things harder to read.

15:44 kotarak: But it should really work as in: (-> 5 #(inc %))...

15:44 Chouser: I would suggest both my above examples fall in the "don't you dare" category.

15:44 hiredman: cool like riding a motorcycle with no helmet

15:44 kotarak: after the "here be dragons" sign

15:45 holmak: I'm thinking I should find another way of writing the section of code.

15:46 Chouser: -> is brilliant for expressions like: (-> "tmp.txt" File. FileReader. BufferedReader. line-seq)

15:47 Chousuke: I see it as a generalised ..

15:47 hiredman: yes

15:47 kotarak: or: (-> (var reduce) meta :ns ns-name name)

15:47 very handy indeed

15:47 holmak: My problem is that (let [dbl #(* 2 %)] (-> 42 dbl)) is not the same as (-> 42 #(* 2 %))

15:48 kotarak: (-> 42 (* 2)) ?

15:48 Chousuke: holmak: the reason for that is simple, though

15:48 since #(* 2 %) expands to a list

15:48 holmak: Oh, I understand why, but substitution like that feels like it should work.

15:49 Chousuke: I don't see a simple way to make it work though.

15:49 hiredman: holmak: http://www.thelastcitadel.com/blag/pipe_macro

15:49 Chousuke: besides some special handling for #() :/

15:49 holmak: The other thing is that the error was extremely unhelpful.

15:49 hiredman: I think that maybe an icky macro

15:50 holmak: That's the bigger problem: java.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.ISeq

15:50 kotarak: I think the problem is, that #() is expanded by the reader.

15:51 holmak: Maybe the documentation should have a warning about using #() with -> ?

15:53 hiredman: That pipe macro is interesting.

15:53 hiredman: "# signals a reader macro, there be dragons"

15:53 RSchulz: holmak: Clojure's error diagnostics are meant as a form of aversive therapy to accelerate your learning and deter incorrect ussage.

15:53 holmak: "Don't get errors, because they will be completely and utterly unhelpful" ?

15:53 :D

15:55 RSchulz: Yeah. something like that.

15:55 Chouser: what should the error be, in that case, and how would the code detect it?

15:56 holmak: I have no idea, there's really nothing that can be done, probably. I was just really puzzled.

15:56 hiredman: "I've noticed you are using ->, I bet you think you're clever don't you? EXCEPTION!"

15:57 RSchulz: I think, very generally speaking, the extreme parsimony of a language like Clojure is an impediment to error diagnostics. In a language like Java which is so verbose, there are more (in some sense) redundant queues that the compiler / interpreter can use to clarify their error messages.

15:57 holmak: Clearly what is needed is an ExcessiveClevernessException

15:57 RSchulz: "My master told me I was clever. I thought it was a complement. He meant it as an insult."

15:58 (Or "compliment," as the case may be...)

15:58 holmak: RShulz: I agree completely. It's kind of hard to write an actual invalid form in Clojure. You just end up writing something valid, but nonsensical.

16:03 lisppaste8: kotarak pasted "Voodoo ->?" at http://paste.lisp.org/display/72311

16:05 hiredman: it's a recursive macro, I guess

16:05 RSchulz: holmak: Or something the error of which is detected a distant point of execution.

16:06 kotarak: "Debugging code is harder than programming it. So if you code as clever as you can - by definition - you wont be able to debug it." (Free after Kernighan? maybe?)

16:09 hiredman: which is why you need a repl

16:09 kotarak: Earnestly: can we use fn* as marker for #()? One isn't supposed to use it anyway.

16:10 RSchulz: Should we not avoid using undocumented forms?

16:12 kotarak: We don't use it. Just as a marker. (but in the end this is still a bad idea...)

16:23 drewr: What is the value of *ns* supposed to be if I've declared (ns foo.bar) right before referencing it?

16:23 I keep getting clojure.core.

16:23 I'd rather get foo.bar.

16:25 hiredman: I get foo.bar

16:25 Chouser: drewr: in the next top-level form, *ns* should be foo.bar

16:26 hiredman: hiredman.clojurebot=> (do (ns foo.bar) (prn *ns*) (in-ns 'hiredman.clojurebot))

16:26 #<Namespace foo.bar>

16:26 #<Namespace hiredman.clojurebot>

16:26 hiredman.clojurebot=>

16:28 drewr: It's inside of a defn and a let.

16:29 hiredman: juggling namespaces inside a defn does not sound like a good idea

16:29 and you'll never get me to admit that I do it

16:30 RSchulz: Not an open-source kinda' guy?

16:31 hiredman: just in denial

16:33 danlarkin: drewr: the ns macro is designed to be used once per file at the top

16:33 not in a function or a let

16:33 drewr: I see. *ns* is the current namespace of the *caller* of a fn.

16:34 RSchulz: Open source kind of undermines the plausibility of one's denials...

16:34 hiredman: RSchulz: I am in denial about that

16:34 drewr: How can I get to the enclosing namespace of a fn?

16:35 RSchulz: ^#'find-doc

16:35 (Using find-doc as an example)

16:36 drewr: To be explicit, the namespace is an element of the metadata of the Var holding the entity in question.

16:36 drewr: OK, it's in the meta, but then I need to know the name of the function. :-/

16:36 Is there no way to say "give me the namespace that owns the fn I'm in?"

16:37 RSchulz: It's like buying a household appliance that will tell you the address of the house in which you've installed it.

16:37 (which is my clever way of saying that's static information.)

16:37 alphazero: hi all.

16:38 Chouser: drewr: you want this info at runtime?

16:38 alphazero: I'm trying to run ants.clj and am getting Exception in thread "main" java.lang.Exception: Unable to resolve symbol: setColor in this context (ants.clj:234)

16:38 drewr: Chouser: Yep.

16:38 alphazero: (defn fill-cell [#^Graphics g x y c]

16:38 (doto g

16:38 (setColor c)

16:38 (fillRect (* x scale) (* y scale) scale scale)))

16:39 Chouser: alphazero: try .setColor and .fillRect (note the dots)

16:39 alphazero: running from svn 1162

16:39 hiredman: old doto syntax

16:39 alphazero: Chouser: Thanks, I'll do that.

16:43 rhickey: alphazero: the ants.clj on the Google Group has that change already

16:43 Chouser: heh. didn't recognize the code.

16:43 rhickey: http://clojure.googlegroups.com/web/ants.clj

16:43 alphazero: rhickey: thanks! that saves time!

16:45 excuse the newb q, but typing clj ants.clj puts up the frame and the blue square but then nothing.

16:46 nevermind, just saw the (comment ..)

16:50 hmm. changed the /Users/rich/.. to load local file ./ants.clj. and have uncommented the demo block

16:50 now it simply keeps flashing the frame, my dual cores going at ~ 60% each. no ants :(

16:52 this is the beginning of a very long stack trace:

16:52 Exception in thread "main" java.lang.OutOfMemoryError: PermGen space (ants.clj:215)

16:52 at clojure.lang.Compiler.analyzeSeq(Compiler.java:4113)

16:52 at clojure.lang.Compiler.analyze(Compiler.java:3935)

16:52 at clojure.lang.Compiler.analyzeSeq(Compiler.java:4094)

16:52 at clojure.lang.Compiler.analyze(Compiler.java:3935)

16:52 at clojure.lang.Compiler.analyze(Compiler.java:3908)

16:52 at clojure.lang.Compiler$NewExpr$Parser.parse(Compiler.java:2150)

16:52 at clojure.lang.Compiler.analyzeSeq(Compiler.java:4106)

16:52 Running on Mac OS X 10.4 with 1132MB of free mem.

16:52 Chousuke: alphazero: next time, please use pastebin :)

16:53 lisppaste8: url

16:53 lisppaste8: To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.

16:53 Chousuke: there

16:53 alphazero: Chousuke: Sorry, will do.

16:54 lisppaste8: alphazero pasted "stack trace ants.clj svn 1162 mac os x 10.4 std clj shell script" at http://paste.lisp.org/display/72318

16:54 Chousuke: alphazero: anyway; the default java heap size is limited, you might want to try running java with the -server option

16:54 alphazero: Chousuke: k, let me try that.

16:54 RSchulz: Chousuke: I don't know about Java on the Mac, but I don't think -server will change the heap allocation. That'x -XmxNNN

16:55 Chousuke: IIRC -server raises it to 128MB

16:55 from 64 or something

16:55 RSchulz: Really? I didn't know that.

16:56 walters: permgen space is special

16:56 rsynnott: '-server' is a very poorly named option

16:56 walters: if you search for "java permgen" you'll get a lot of hits, http://blogs.sun.com/fkieviet/entry/classloader_leaks_the_dreaded_java is one

16:57 Chousuke: RSchulz: "There is not a distinct server VM for Mac OS X. Although you may use the -server flag when invoking java, it does not start up a different VM, instead it starts the client VM that has been tuned for use in a server environment." and heap size is included in the tuned parameters :)

16:57 walters: basically it's the area where class code is loaded; in most GCs it's a fixed size, and you need special options to enable collecting it

16:57 RSchulz: Great. Thanks.

16:57 I knew they were integrated, but the default heap size adjustment had escaped my notice.

16:59 alphazero: Well, -server seemed to have pushed cpu util to ~80% but basically same behavior. not a single ant even showed up, just flashing the screen with a blue box.

17:02 Chousuke: hmm

17:03 rhickey: alphazero: the code in the comments is not supposed to be uncommented, then loaded (will recursively load itself if you do that. It's meant for a demo - load the file (which the first commented line does), then eval the other lines

17:03 it's not an executable script

17:04 Chousuke: apparently I can't wget stuff from google code easily :/

17:04 rsynnott: alphazero: I think -server is far more aggressive about JITing, which may help to explain the extra processor usage

17:04 Chousuke: the file link takes me to some stupid clickthrough page :P

17:04 alphazero: rhickey: so how do I run ants.clj? from Repl?

17:04 Chousuke: alphazero: emacs & slime works very well :)

17:05 you can eval the entire file and then just eval the code inside the comment separately

17:05 alphazero: Chousuke: damn it, I'm drawing the line at (((((()))))) .. ;)

17:05 rhickey: alphazero: I load it into emacs, then run each line in the comments one by one, for demo

17:06 but your problem definitely is that it is loading itself infinitely recursively

17:06 blowing permgen on compilation

17:06 alphazero: rhickey: well, i'm not setup for that yet. so no way to run this simply from Repl?

17:07 Chouser: alphazero: yes

17:07 java -cp clojure.jar clojure.lang.Repl ants.clj

17:07 then paste each of the lines from the comment section into the repl, one by one

17:08 Chousuke: you really should consider using emacs. it's worth it just for slime :P

17:08 Chouser: middle-click-paste on X-windows makes this a breeze, but I imagine MacOS will let you do what you need to with Command-V

17:09 triddell: alphazero: if the REPL is already started the first line in the comments is (load-file ...

17:09 just point to your ants.clj

17:09 then run the other lines in comments

17:09 alphazero: Chouser: that's what I have been doing. sorry being dense. + installed acquamacs and went through the whole clojure-mode thing. but the whole C-c (type type type type) thing just to do simple stuff. So much fun ..

17:12 Hey, success! Thank ya'll for your patience.

17:12 Chouser: Chousuke: I'm glad you find slime worth while. I'll refrain from saying anything else.

17:14 Chousuke: heh

17:14 well I can handle editing in emacs with viper :P

17:15 though I do use some of the less offensive emacs shortcuts too.

17:15 having caps lock as control really help

17:15 s

17:15 * Chouser agrees with that.

17:17 Chouser: I guess the only other thing I'll say about emacs here is that I hope people's advocacy of emacs+slime+swank and of using the latest svn (which also then requires svn, ant, javac) doesn't turn people off

17:17 ...when all they really need is their favorite text editor, clojure.jar, and a JVM.

17:17 at least to get started.

17:17 Chousuke: well, I guess we can start recommending 1.0 after it's out

17:18 danm_: although, writing lisp in an editor which doesn't speak parens is somewhat frustrating

17:18 Chouser: Chousuke: only if there's a perfectly-matched slime setup for 1.0 available, right?

17:18 Chousuke: well, there is that clojurebox thing

17:18 Chouser: for Windows

17:19 ...and still you're going to spend time learning emacs instead of clojure

17:20 Chousuke: I suppose.

17:20 now if I could figure out why my aquamacs insists on opening two windows on startup I'd be happy.

17:20 hiredman: clojurebot: emacs?

17:20 clojurebot: but I like using notepad++!

17:21 hiredman: actaully I did a few euler problems in notepad++

17:23 gnuvince_: You wrote the solution in notepad++ or you actually used notepad++ to solve them?

17:25 hiredman: a solution using clojure in notepad++

17:25 Chouser: now, writing notepad++ using a solution in clojure, why that'd be something.

17:26 * Chouser aplogizes and gets back to work.

17:26 gnuvince_: ;)

18:12 triddell: Using a java library class I've slurped up some file contents into a java.util.Hashmap. Is this object a seq? Can I use standard clojure functions on a java Hashap?

18:12 this was created: #=(java.util.HashMap. {"key1" "value1", "key2" "value2"})

18:14 if this object is represented by *config* how would I access the values, etc.?

18:15 rhickey: triddell: if you seq it you will get a seq of Map.Entry, but loys of things work on them, like, key, val, and destructuring:

18:15 (map (fn [[k v]] [k v]) #=(java.util.HashMap. {"key1" "value1", "key2" "value2"}))

18:15 (["key1" "value1"] ["key2" "value2"])

18:17 also:

18:17 user=> (for [[k v] #=(java.util.HashMap. {"key1" "value1", "key2" "value2"})] [k v])

18:17 (["key1" "value1"] ["key2" "value2"])

18:17 user=> (keys #=(java.util.HashMap. {"key1" "value1", "key2" "value2"}))

18:17 ("key1" "key2")

18:17 etc

18:18 triddell: thanks rich!

18:18 meredydd: Is #= new?

18:18 fyuryu: triddell: if you want to turn it into a persistent hash map: (into {} your-hashmap)

18:19 rhickey: meredydd: don't use #= in your code

18:19 fyuryu: triddell: less noise on the repl

18:19 meredydd: You just used it in a fragment there. What does it do?

18:20 triddell: fyuryu: I'll try that

18:20 rhickey: meredydd: nothing that (java.util.HashMap. {"key1" "value1", "key2" "value2"}) doesn't, I just grabbed it from his output

18:21 it's a print-dup format for serialization - you won't see them at the repl at all soon

18:23 meredydd: ah...a quick google suggests you're doing something with generic-ising the print functions

19:55 clojurebot: svn rev 1173; updated readme with run and build lines

20:04 triddell: another simple question... I have a map which I can read a key from like (get *YAML-config* "context-root")... and this is true: (contains? *YAML-config* "context-root")... but why cant I do this (:context-root *YAML-config*)

20:06 Chouser: the string "context-root" is different from the keyword :context-root

20:07 triddell: right, I'm trying to understand the "maps of their keys" piece

20:07 I mean functions of their keys

20:07 Chouser: oh, that's just (*YAML-config* "context-root")

20:07 phf: triddell: functions of their keys should be opposed order

20:07 what Chouser said

20:09 triddell: ah, ok, thanks

20:23 rhickey: New release: http://clojure.googlecode.com/files/clojure_20081217.zip (for your friends that aren't on SVN yet)

20:24 Chousuke: hooray. now the release version will actually work with most of the examples in the wiki and other sources :)

20:24 rhickey: I could use some help going over the docs/examples looking for inaccuracies or anachronisms

20:24 e.g. trying every example

20:35 qebab: Hi. I've decided to spend some time during christmas picking up clojure. Could anyone tell me something about how it'd feel for someone who usually programs python but hacks scheme and C on the side? :)

20:36 hiredman: of those three it is most like scheme

20:36 Chouser: qebab: it feels like a fresh sea breeze on a stifling hot day

20:38 qebab: hiredman: unsurprising, since it's the only lisp in that list :) I noticed an example on clojure.org that seems to use pattern-matching. how does that relate to pattern matching in languages like haskell?

20:38 Chouser: Clojure does not have haskell-like pattern matching, but it does have handy destructuring.

20:38 qebab: Chouser: that is good to hear, it's been a long half year with 3 very boring classes, so I need something to motivate myself for further hacking next year

20:39 aha, so that's what it is

20:39 phf: qebab: there's also dispatch on the number of arguments

20:39 qebab: does it work on all datastructures that have builtin syntax?

20:39 phf: but i think that's mostly a mapping to java world

20:39 Chouser: qebab: yes

20:39 qebab: cool

20:40 hiredman: clojure has dispatching on any function of the arguments to a function

20:40 Chouser: qebab: if you don't mind the format, watch one of the screencasts -- probably the one on sequences

20:40 that'll get you motivated.

20:40 qebab: my first impression is that this is common-lisp with a whole bunch of bad design choices removed, and lots of good ideas added

20:41 Chousuke: that's not a bad first impression I guess.

20:41 not optimal either though.

20:41 Chouser: yeah, it doesn't feel like common lisp to me.

20:42 qebab: well, I prefer scheme to common lisp, but find the latter more practical... I'm hoping that clojure will be both practical and nice :)

20:42 Chousuke: the java interop is perhaps underappreciated. a lot of clojure "Just Works" with java.

20:43 qebab: yeah, looks like a very nice feature

20:43 hiredman: which is really nice

20:45 qebab: there are tons of cool examples, that's for sure

20:46 is there a handy documentation searching function?

20:46 Chousuke: (doc find-doc)

20:46 clojurebot: Prints documentation for any var whose documentation or name contains a match for re-string-or-pattern; arglists ([re-string-or-pattern])

20:47 qebab: something like help() without parameters does in python (Let's you search in docstrings and module documentation and things like that)

20:47 oh, neat

20:47 thanks

20:47 Chousuke: it's not very easily browseable though.

20:48 hiredman: bookmark clojure.org/api

20:48 Chousuke: it should be pretty straightforward to use find-doc as a basis for some kind of function that uses clojure.inspector for browsing the results.

20:49 qebab: this works nicely for now, I'm basically just working out what the functions I'm used to from scheme/cl are called here

20:50 Chousuke: the wikibook tutorials and tips section has something about that.

20:50 the book is in pretty bad shape still, but hopefully it will improve :P

20:51 hiredman: clojurebot: map?

20:51 clojurebot: map is *LAZY*

20:53 phf: which allows for some ... interesting debugging situations in combination with local bindings

20:53 qebab: ohh, map is lazy :o

20:54 Chousuke: qebab: most of the seq-consuming functions in clojure are

20:54 be aware of this when dealing with functions that have side-effects :)

20:55 qebab: Chousuke: I've programmed a fair bit of haskell (Of course, there you have the type-system babysitter, but still...), so I should do fine on that count :)

20:55 Chousuke: to avoid mapping #(println "hello" %) over a collection and wondering why it does nothing

20:55 qebab: gah

20:55 I just managed to pour coffee on my desk

20:58 RSchulz: Pouring coffee on your desk is a challenge, so you should feel proud!

20:59 hiredman: clojurebot: qebab likes haskell

20:59 clojurebot: excusez-moi

20:59 hiredman: damn it

21:00 hmmm

21:00 qebab: clojurebot: help

21:00 clojurebot: I don't understand.

21:00 qebab: what can it do?

21:01 hiredman: what would you say if I told you qebab likes haskell?

21:01 * hiredman fails again

21:01 hiredman: clojurebot: what would you say if I told you qebab likes haskell?

21:01 clojurebot: Yo dawg, I heard you like Haskell, so I put a lazy thunk inside a lazy thunk so you don't have to compute while you compute.

21:01 hiredman: qebab: not much

21:01 qebab: okay

21:02 hiredman: does docs

21:02 (doc trampoline)

21:02 clojurebot: trampoline can be used to convert algorithms requiring mutual recursion without stack consumption. Calls f with supplied args, if any. If f returns a fn, calls that fn with no arguments, and continues to repeat, until the return value is not a fn, then returns that non-fn value. Note that if you want to return a fn as a final value, you must wrap it in some data structure and unpack it after trampoline returns

21:02 qebab: that's useful

21:03 oh, you can optionally name lambdas so they can recurse?

21:03 hiredman: yes

21:04 (fn a [x] (a x))

21:04 qebab: that's pretty awesome

21:27 RSchulz: qebab: Whether a fn / lambda has a name or not (is the binding of a Var) changes nothing about how or where it may be used / invoked in Clojure.

21:48 triddell: what's the best way to recode a switch statement in clojure/lisp?

21:48 durka: look at cond

21:49 triddell: got it, thx

23:00 timothypratley: is there a way to search for a value in a vector... like (contains? \e "efg") <-- but that wont work because it works on maps

23:01 Chouser: (some #{:c} [:a :b :c :d :e])

23:05 timothypratley: ah... so

23:05 user=> (some #(= %1 \e) "efg")

23:05 true

23:05 user=> (some #(= %1 \e) "afg")

23:05 nil

23:05 thanks

23:07 Chouser: or (some #{\f} "efg")

23:08 timothypratley: even better!

23:54 triddell: Anybody here use the html generation features of Compojure?

23:56 It's based on nested vector syntax and I have a need to create some repeating blocks of html/xml.... but I need to open a new file for each repeated block... hopefully that is possible.

23:58 Would one typically use a for comprehension to process a list of files?

23:59 dhaya: triddell: side effects are typically done with doseq

Logging service provided by n01se.net