#clojure logs

2008-12-17

00:05bradbevare def's evaluated at compile time when AOT compilation is used?
00:06bradbevI 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
00:10Chousereverything gets evaluated when you compile -- it's just like a normal run, except generated class files are saved out along the way.
00:11bradbevso how does that actually work if I construct Java objects in defs - how do they get saved?
00:12hiredmanthey don't
00:12Chouseroh, good, because I didn't know.
00:12Chouserhiredman: the code to generate them gets compiled and then new ones are made when the compiled code gets run?
00:13hiredmanyeah
00:13hiredmanmean, it must right?
00:13hiredmanthe other way is just crazy
00:13bradbevwhich also means that at compile time the defs need to be able to execute
00:13bradbevmy use-case is that I have a hash-map to describe a gui & a couple of functions to load/show it
00:13hiredmanbradbev: there is some var that is set at compile time you can (if ) around
00:13bradbevI construct the Swing objects in the def
00:16dhayathis 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?
00:17hiredmanbut rhickey did not go through and add print-dup ability to all java objects
00:17hiredmanclojurebot: rhickey?
00:17clojurebothe works hard so you don't have to
00:18bradbevhmm, I'm not sure that's the same thing at all
00:18hiredmanprint-dup is for clojure data structures I think, because certain clojure data structures can have different underlying impls
00:18bradbevif the def was not evaluated at AOT, but was evaluated at load then I'd be fine
00:19dhayaThere is a *compile-files* flag that you can use to prevent evaluation during AOT compilation.
00:20hiredmanbradbev: *compile-files* is true when you are compiling
00:20bradbevOK
00:20hiredman(def a (when-not *compile-files* (my-big-init)))
00:21hiredmandhaya: beat me
00:21bradbevnow, the other thing that is screwy is (defn frame (JFrame. "foo")) also causes ant to break during compile
00:21bradbevthat should be lazy evaled, right?
00:21hiredmanuh
00:21hiredmanno
00:21hiredmanoh
00:21hiredmandefn not def
00:21bradbevoh, crap - how did that even compile though?
00:21hiredman*shrug*
00:22hiredmanwell it did nae compile did it?
00:22bradbevheh, true
00:23bradbevok, converting from a def to a defn & a call fixes the issue
00:24bradbevthough it does leave the problem that defs are evaled at compile time & they may construct java objects
00:26hiredmanthat is what *compile-files* is for
00:27hiredmancompile and load are kind of the same thing, compile just also outputs class files
00:27bradbevyeah, wrapping the def in (if (not *compile-files*)) works
00:28bradbevthanks for the help
00:28dhayabradbev: (when-not might more idiomatic i think..
00:29bradbevdhaya: thanks - I didn't know about that (I did know unless isn't there :))
00:30dhayaI have no idea about unless. is that a CL thing?
00:31hiredmanruby has it
00:31dhayaah..ok.
00:32bradbevCL has it also
01:06wipewindowswhich should I ask for as a christmas prsent, im a strange loop or GED?
01:11cadswipewindows, I'd just download some of godel's papers, buy some escher prints, and enjoy some pirated bach
01:13cadsit's a lot of dumbed down philosophy and the author tries to get across how wonderful and strange our consciousness (his consciousness) is
02:48dmilesany DotLisp hackers in here atm?
02:50dmilestrying to figure out where (Hex/DecodeHexString text) comes from
04:11AWizzArdclojurebot: max people
04:11clojurebotmax people is 116
10:22rhickeyany contrib-ers out there? move to gc go ok?
10:24Chousukeis everything in contrib EPL now?
10:32rhickeyChousuke: yes
10:55RSchulzI just checked it out and built it without a hitch.
10:57AWizzArdrhickey: what again was the title of this book about concurrency in Java?
10:57rhickeyJava Concurrency in Practice
10:57AWizzArdthx
10:58duck1123reading chapter 6.2.5
10:59gnuvinceWouldn't that be a section of chapter 6?
10:59gnuvince</anal>
11:08kyleburton/?
11:08kyleburtoner, does there happen to be a way to know the name of the form being defined?
11:09rhickeykyleburton: for what to know?
11:09kyleburtonwell, I was toying with creating a log form
11:09kyleburtonand it'd be nice to know the file name (if available), line number and fn name
11:09rhickeyChouser: what's the alternative?
11:09kyleburtonso it could expand to including that in the log stmt
11:09kyleburtoneg: (defn some-func [] (log-debug "foo"))
11:10kyleburtonit'd be nice if that could expand into something like:
11:10kyleburton(defn some-func [] (log/log-debug "test.clj" 107 "some-func" "foo"))
11:10wlr_google code's clojure-contrib still has svn/trunk/CPL.txt
11:11kyleburtonwell, really w/the args wraped in a lambda so they dont get computed unless the levle is that high
11:11kyleburtonkind of like __pretty_function__, __LINE__ and __FILE__
11:11kyleburtonwell, exactly like those
11:12Chouserrhickey: I don't suppose there's any way to display those rules on the "new issue" form?
11:13duck1123Chouser: where are these rules?
11:13Chouserduck1123: exactly.
11:14rhickeyChouser: I can pre-fill the description box with text, some of the rules are there
11:15Chouserok. I don't have a good alternative. Maybe some firm policing will be sufficient.
11:16Chouserduck1123: rules: http://groups.google.com/group/clojure/browse_thread/thread/1a4fe97a957ec52a
11:18rhickeyChouser: ok, full set of rules now in the entry form
11:19duck1123now that the issue tracker is being used, should clojurebot announce new tickets?
11:19Chouserkyleburton: (defmacro log [msg] `(prn ~msg ~*file*))
11:20rhickeyduck1123: there is a dev feed, just trying to get it set up the way I want
11:20kyleburtonok, *file* is good, is there a *line* and perhaps a *top-level-form-name*?
11:20Chouserkyleburton: looks like there's currently no similar way to get to the line number.
11:20kyleburtonChouser: thank you re: *file*
11:20Chouserkyleburton: but both are available as metadata of the var -- 'some-func' in your example.
11:21kyleburtonChouser: yes, but how can you get the name of the enclosing top level form so the macro can see it?
11:21Chouser...but I don't think the name of that var is available to the expression being evaluated for the var's value.
11:21rhickeyChouser: *file* isn't going to help there, as it's value at runtime will be nil
11:21kyleburtonrhickey: even if you expand with ~*file*?
11:22rhickeyi.e. a macro can use it, but to emit it doesn't help
11:22kyleburtonrhickey: doens't that get resolved at compile...
11:22Chouserrhickey: sure, but in that macro I posted the compile-time value of *file* is inserted into the expression
11:22rhickeythat's all this is for? nevermind
11:22gnuvinceDoes Java allow mutating final fields?
11:23Chousergnuvince: don't think so. I think that's the point of them being final.
11:24AWizzArdI think Clojure declares a lot of stuff as final under the hood, to come to its performance.
11:25gnuvinceChouser: I wasn't sure what final meant for fields.
11:32RSchulzA 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:32RSchulzIt's not at all like C++ const.
11:32RSchulzOops. That came out mangled.
11:32Chousukeit's more like a const*
11:33Chousukeor is that *const? :P
11:33RSchulzYou can't reassing a final field after initialization, which must happen by the time the constructors exit.
11:33RSchulzBut you can call any method on the values in such fields.
11:33RSchulzChousuke: Yes, it's like *const.
11:44aperotteChouser: I figured out why I was getting different behavior when using (load-file ...) versus evaluating each form in the file
11:45aperotteChouser: 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:46aperotteChouser: 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:50Chouseraperotte: ah, very good!
11:50Chouserthanks for bringing me up-to-date. That's likely to come up again.
11:51aperotteNo problem, thanks for the help
11:51aperotteRSchultz: Thanks for your help in trying to figure this out as well.
11:57Lau_of_DKGood evening all
12:00ericthorsenI 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:02rhickeythe require is for a .clj file? not compiled?
12:02ericthorsenrhickey: yes
12:03rhickeyericthorsen: you might have a much easier time if you compiled it
12:04rhickeyit's probably related to classloader that loaded Clojure doesn't have access to that module?
12:06ericthorsenrhickey: yes...we are going down that path as well.
12:07rhickeyericthorsen: 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:25rhickeyhttp://groups.google.com/group/clojure-dev - read-only via web/xml, will get all issue changes for clojure and contrib
12:32rhickeyhrm, wiki edits go in svn revision stream...
12:34RSchulzaperotte: 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:35ffaillaI 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:59tomhickeyrhickey: i see the wiki edits in the revision list on the site, but not in my svn client
13:00rhickeytomhickey: you're probably just pulling trunk - the wiki is a sibling of trunk, not under it
13:01tomhickeyrhickey: ah, i see
13:32Chousersuccess!
13:33rhickeyNot really, as I need patches/bug-reports to go there, getting lost in group traffic
13:33Lau_of_DK Rich, it looks good, not scared :)
13:36RSchulzrhickey: 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:36RSchulzCase in point: How to get (shutdown-agents) to work without explicitly calling it. The list thread didn't end up with a resolution.
13:37rhickeyRSchulz: probably not, we should be able to resolve bug or desirable feature on the group
13:37rhickeyAs far as that one, I don't see why clojure should do something specific, you have shutdown-agents
13:37kotarakRSchulz: maybe the Repl could be modified to allow shutdown-hooks?
13:38rhickeybut in any case, the issues list is not for advocacy
13:38RSchulzI'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:41rhickeyRSchulz: 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:43kotarakWhen 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:43RSchulzHow 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:43RSchulzrhickey: 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:44ChouserRSchulz: when to shutdown background threads is an application-wide question, not something that can be answered in smaller pieces, it seems to me.
13:44RSchulzRight. And I'd like to make it work in a generic way: via JVM shutdown hooks. That seems eminently reasonable to me.
13:45ChouserRSchulz: what makes you think the JVM shutdown hooks will run before all the threads have quit?
13:45rhickeyRSchulz: this is a pure Java problem - the agents just use the Executors framework
13:45RSchulzEh? I want it to run as part of the JVM shutdown processing. That's what they're for, right?
13:45rhickeyRSchulz: shutdown happens after all threads are done
13:46RSchulzSo what's the problem? Why do I hang upon CTRL-D from the REPL unless I call (shutdown-agents) _from_ the REPL?
13:46RSchulzSo it's a chicken-and-egg thing?
13:46rhickeyctrl-d works for me
13:46RSchulzrhickey: When you've started agents?
13:46waltersthe threads have to be daemon threads (see Thread.setDaemon)
13:46RSchulzAgents that _have_ been (await ...) -ed?
13:47rhickeyRSchulz: there-s your problem - your awaiting and not geting your ctrl-d
13:47RSchulzEh?
13:47RSchulzEvery agent I start gets awaited. Then later on when I CTRL-D, it hangs.
13:47rhickeyyou're blocked in await and don't see eof
13:48RSchulzI'm _not_ blocked in await. It returns. Otherwise I wouldnt' get the next REPL prompt.
13:48RSchulzI can do much stuff after returning from await and then when I CTRL-D, it hangs.
13:49rhickeyRSchulz: please write a small example program that demonstrates your problem. Debugging english descriptions is impossible
13:49RSchulzAnd do what with it?
13:49RSchulzSend it to the list?
13:49RSchulzThe reason I'm here now is that that thread on the list didn't get any resolution...
13:50rhickeyyeah, or paste here. You're saying you have a problem - help us replicate it. You didn't post code there either.
13:51rhickeycan't replicate, can;t fix. Giving a verbal description puts the onus on others to write a test case to reproduce the problem
13:51ChouserRSchulz: is this clojure.lang.Repl, or some other Repl?
13:51RSchulzThe Contrib REPL.
13:52Chouserclojure.lang.Repl does a System/exit after ^D, which doesn't hang on the agent pools.
13:55AWizzArdCan I find out the path in which my program was run? If yes, how?
14:00Lau_of_DKOnus.... :)
14:01rhickeyChouser: I wonder if this unifying patch still does that? http://groups.google.com/group/clojure/browse_frm/thread/2aeb7bdc789d5933#
14:02RSchulzOK. There it is (on the list).
14:04Chouserrhickey: 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:05ChouserI've got completely hangled classloaders at the moment.
14:05Chousermangled
14:23AWizzArdIs there something like read-line for files, which returns a vector of strings (of the lines of that file)?
14:23Chouser(doc line-seq)
14:23clojurebotReturns the lines of text from rdr as a lazy sequence of strings. rdr must implement java.io.BufferedReader.; arglists ([rdr])
14:23kotarakThere is line-seq.
14:24AWizzArdOkay, so that is a bit closer to what I meant, thanks
14:25AWizzArdomg, I just saw http://www.roseindia.net/java/beginners/java-read-file-line-by-line.shtml
14:25AWizzArdwhy not just say (map function (lines "myfile.txt")) ?
14:26AWizzArd4x new in that file, uh!!
14:26AWizzArd"new"
14:26Chouserto be fair, a couple of those are still needed with line-seq
14:27Chouseronly with duck-streams to we start to rise above
14:27waltersthat DataInputStream is unnecessary, you only need FileReader and BufferedReader
14:28walters(i'm not defending the bewildering lack of File.open() in the JDK, but it's not quite that bad)
14:30AWizzArdI think the easiest really is to use the ds/reader + line-seq.
14:30AWizzArdBut ds/reader is not lazy, right? So it will read the whole file, may it be 50 bytes or 3 GB, yes?
14:34Chouserno, ds/reader just creates an appropriate java.io object, it doesn't actually read anything.
14:35AWizzArdokay, and line-seq itself is lazy
14:35AWizzArdso 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:37rhickeyChouser: nice post to code with line number in google code!
14:37rhickeyvery useful
14:38ChouserI've been wanting to do that, but sf.net was just too slow to be useful.
14:39Chouserthe rev number is in there too, so reading that thread a few weeks from now it should still make sense.
14:39rhickeysaw that, very nice
14:42rhickeycode browsing seems very peppy
14:45Lau_of_DKrhickey: That "issue tracker" doesnt really seem to be the right tool for the job ?
14:46rhickeyLau_of_DK: how so?
14:46RSchulzIs there a way to get GC to colorize .clj files?
14:46Lau_of_DKrhickey: 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:47kotarakAt least the template chooser could be more prominent. (And also marked as necessary for the type of issue)
14:58hiredmanso clojure svn is in google code now?
14:58Chouserhiredman: yes
14:58hiredmanclojurebot: svn is svn checkout http://clojure.googlecode.com/svn/trunk/ clojure-read-only
14:58clojurebotYou don't have to tell me twice.
14:59Lau_of_DKChouser: Have we switched away from Sourceforge to Googlecode?
14:59Chouseryes
14:59Lau_of_DKFor what reason ?
15:00hiredmansf is :(
15:00Chousermore features, better response time
15:01danm_google code sure is faster
15:02Lau_of_DKChouser: Am I to understand that we yet again missed a golden opportunity to switch to Git ? :)
15:02Chousernope. switching to git is still a dead subject (imo) until Rich brings it up.
15:03Lau_of_DKChouser: k
15:04hiredmanclojurebot: relocate is svn switch --relocate file:/$PWD http://clojure.googlecode.com/svn/
15:04clojurebotc'est bon!
15:04jimmThe download link on clojure.org still points to Subversion. Is that intended?
15:05Chouserthat's the only place to get a .zip for now, I think.
15:05rhickeyjimm: that's where the download is until the next release
15:05jimmrhickey: thank you
15:05jimmI see, the SVN link has been updated to google code
15:06hiredmansvn rev 1162
15:07clojurebotsvn rev 1162; EPL in header
15:07clojurebotsvn rev 1168; Edited wiki page through web user interface.
15:07clojurebotsvn rev 1169; Edited wiki page through web user interface.
15:07clojurebotsvn rev 1170; Edited wiki page through web user interface.
15:07clojurebotsvn rev 1171; Edited wiki page through web user interface.
15:07clojurebotsvn rev 1172; Edited wiki page through web user interface.
15:07hiredmaneeep
15:09rhickeyI'll start putting comments on wiki edits since they're going in svn
15:11hiredmanmaybe I should filter wiki edits out?
15:12Chouserhiredman: 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:13Chouserthat's very interesting, though -- the wiki is stored in the projects own svn repo.
15:13hiredmanit's cute
15:14hiredmangah, that svn relocate deal doesn't really work
15:17clojurebotsvn rev 1168; Edited wiki page through web user interface.
15:17clojurebotsvn rev 1169; Edited wiki page through web user interface.
15:17clojurebotsvn rev 1170; Edited wiki page through web user interface.
15:17clojurebotsvn rev 1171; Edited wiki page through web user interface.
15:17clojurebotsvn rev 1172; Edited wiki page through web user interface.
15:17hiredmanclojurebot: stop that
15:17clojurebotI don't understand.
15:38holmakApparently it is not acceptable to use the #() anonymous function form inside (-> ...) -- is this expected?
15:38kotarakholmak: you have to take care (-> x (#(do-something %)))
15:39holmakah
15:39Chouserhm.
15:39holmakI guess -> was interacting poorly with the #() macro.
15:40Chouserindeed, the item to the left of #() is used as the name of the anonymous function
15:40holmakI thought since #(...) makes a function, -> ought to treat it as a non-list, and turn it into (#(...) arg)
15:40holmakThat's obviously not what happens, given the macro expansions
15:42Chouser(-> foo #(+ % 2) (apply [3])) ==> 5
15:42Chouser-> is easy to abuse.
15:42holmakI will use caution, then.
15:42Chouser(-> [i 3] (dotimes (prn i)))
15:42hiredmancute
15:43holmakYou're making it look downright dangerous
15:43holmak"-> considered harmful"
15:43kotarakbah, -> is cool. :)
15:43Chouserwell, just don't use it in circumstances where it makes things harder to read.
15:44kotarakBut it should really work as in: (-> 5 #(inc %))...
15:44ChouserI would suggest both my above examples fall in the "don't you dare" category.
15:44hiredmancool like riding a motorcycle with no helmet
15:44kotarakafter the "here be dragons" sign
15:45holmakI'm thinking I should find another way of writing the section of code.
15:46Chouser-> is brilliant for expressions like: (-> "tmp.txt" File. FileReader. BufferedReader. line-seq)
15:47ChousukeI see it as a generalised ..
15:47hiredmanyes
15:47kotarakor: (-> (var reduce) meta :ns ns-name name)
15:47kotarakvery handy indeed
15:47holmakMy problem is that (let [dbl #(* 2 %)] (-> 42 dbl)) is not the same as (-> 42 #(* 2 %))
15:48kotarak(-> 42 (* 2)) ?
15:48Chousukeholmak: the reason for that is simple, though
15:48Chousukesince #(* 2 %) expands to a list
15:48holmakOh, I understand why, but substitution like that feels like it should work.
15:49ChousukeI don't see a simple way to make it work though.
15:49hiredmanholmak: http://www.thelastcitadel.com/blag/pipe_macro
15:49Chousukebesides some special handling for #() :/
15:49holmakThe other thing is that the error was extremely unhelpful.
15:49hiredmanI think that maybe an icky macro
15:50holmakThat's the bigger problem: java.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.ISeq
15:50kotarakI think the problem is, that #() is expanded by the reader.
15:51holmakMaybe the documentation should have a warning about using #() with -> ?
15:53holmakhiredman: That pipe macro is interesting.
15:53hiredman"# signals a reader macro, there be dragons"
15:53RSchulzholmak: Clojure's error diagnostics are meant as a form of aversive therapy to accelerate your learning and deter incorrect ussage.
15:53holmak"Don't get errors, because they will be completely and utterly unhelpful" ?
15:53holmak:D
15:55RSchulzYeah. something like that.
15:55Chouserwhat should the error be, in that case, and how would the code detect it?
15:56holmakI have no idea, there's really nothing that can be done, probably. I was just really puzzled.
15:56hiredman"I've noticed you are using ->, I bet you think you're clever don't you? EXCEPTION!"
15:57RSchulzI 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:57holmakClearly what is needed is an ExcessiveClevernessException
15:57RSchulz"My master told me I was clever. I thought it was a complement. He meant it as an insult."
15:58RSchulz(Or "compliment," as the case may be...)
15:58holmakRShulz: 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:03lisppaste8kotarak pasted "Voodoo ->?" at http://paste.lisp.org/display/72311
16:05hiredmanit's a recursive macro, I guess
16:05RSchulzholmak: Or something the error of which is detected a distant point of execution.
16:06kotarak"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:09hiredmanwhich is why you need a repl
16:09kotarakEarnestly: can we use fn* as marker for #()? One isn't supposed to use it anyway.
16:10RSchulzShould we not avoid using undocumented forms?
16:12kotarakWe don't use it. Just as a marker. (but in the end this is still a bad idea...)
16:23drewrWhat is the value of *ns* supposed to be if I've declared (ns foo.bar) right before referencing it?
16:23drewrI keep getting clojure.core.
16:23drewrI'd rather get foo.bar.
16:25hiredmanI get foo.bar
16:25Chouserdrewr: in the next top-level form, *ns* should be foo.bar
16:26hiredmanhiredman.clojurebot=> (do (ns foo.bar) (prn *ns*) (in-ns 'hiredman.clojurebot))
16:26hiredman#<Namespace foo.bar>
16:26hiredman#<Namespace hiredman.clojurebot>
16:26hiredmanhiredman.clojurebot=>
16:28drewrIt's inside of a defn and a let.
16:29hiredmanjuggling namespaces inside a defn does not sound like a good idea
16:29hiredmanand you'll never get me to admit that I do it
16:30RSchulzNot an open-source kinda' guy?
16:31hiredmanjust in denial
16:33danlarkindrewr: the ns macro is designed to be used once per file at the top
16:33danlarkinnot in a function or a let
16:33drewrI see. *ns* is the current namespace of the *caller* of a fn.
16:34RSchulzOpen source kind of undermines the plausibility of one's denials...
16:34hiredmanRSchulz: I am in denial about that
16:34drewrHow can I get to the enclosing namespace of a fn?
16:35RSchulz^#'find-doc
16:35RSchulz(Using find-doc as an example)
16:36RSchulzdrewr: To be explicit, the namespace is an element of the metadata of the Var holding the entity in question.
16:36drewrOK, it's in the meta, but then I need to know the name of the function. :-/
16:36drewrIs there no way to say "give me the namespace that owns the fn I'm in?"
16:37RSchulzIt's like buying a household appliance that will tell you the address of the house in which you've installed it.
16:37RSchulz(which is my clever way of saying that's static information.)
16:37alphazerohi all.
16:38Chouserdrewr: you want this info at runtime?
16:38alphazeroI'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:38drewrChouser: Yep.
16:38alphazero(defn fill-cell [#^Graphics g x y c]
16:38alphazero (doto g
16:38alphazero (setColor c)
16:38alphazero (fillRect (* x scale) (* y scale) scale scale)))
16:39Chouseralphazero: try .setColor and .fillRect (note the dots)
16:39alphazerorunning from svn 1162
16:39hiredmanold doto syntax
16:39alphazeroChouser: Thanks, I'll do that.
16:43rhickeyalphazero: the ants.clj on the Google Group has that change already
16:43Chouserheh. didn't recognize the code.
16:43rhickeyhttp://clojure.googlegroups.com/web/ants.clj
16:43alphazerorhickey: thanks! that saves time!
16:45alphazeroexcuse the newb q, but typing clj ants.clj puts up the frame and the blue square but then nothing.
16:46alphazeronevermind, just saw the (comment ..)
16:50alphazerohmm. changed the /Users/rich/.. to load local file ./ants.clj. and have uncommented the demo block
16:50alphazeronow it simply keeps flashing the frame, my dual cores going at ~ 60% each. no ants :(
16:52alphazerothis is the beginning of a very long stack trace:
16:52alphazeroException in thread "main" java.lang.OutOfMemoryError: PermGen space (ants.clj:215)
16:52alphazero at clojure.lang.Compiler.analyzeSeq(Compiler.java:4113)
16:52alphazero at clojure.lang.Compiler.analyze(Compiler.java:3935)
16:52alphazero at clojure.lang.Compiler.analyzeSeq(Compiler.java:4094)
16:52alphazero at clojure.lang.Compiler.analyze(Compiler.java:3935)
16:52alphazero at clojure.lang.Compiler.analyze(Compiler.java:3908)
16:52alphazero at clojure.lang.Compiler$NewExpr$Parser.parse(Compiler.java:2150)
16:52alphazero at clojure.lang.Compiler.analyzeSeq(Compiler.java:4106)
16:52alphazeroRunning on Mac OS X 10.4 with 1132MB of free mem.
16:52Chousukealphazero: next time, please use pastebin :)
16:53Chousukelisppaste8: url
16:53lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
16:53Chousukethere
16:53alphazeroChousuke: Sorry, will do.
16:54lisppaste8alphazero pasted "stack trace ants.clj svn 1162 mac os x 10.4 std clj shell script" at http://paste.lisp.org/display/72318
16:54Chousukealphazero: anyway; the default java heap size is limited, you might want to try running java with the -server option
16:54alphazeroChousuke: k, let me try that.
16:54RSchulzChousuke: I don't know about Java on the Mac, but I don't think -server will change the heap allocation. That'x -XmxNNN
16:55ChousukeIIRC -server raises it to 128MB
16:55Chousukefrom 64 or something
16:55RSchulzReally? I didn't know that.
16:56walterspermgen space is special
16:56rsynnott'-server' is a very poorly named option
16:56waltersif 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:57ChousukeRSchulz: "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:57waltersbasically 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:57RSchulzGreat. Thanks.
16:57RSchulzI knew they were integrated, but the default heap size adjustment had escaped my notice.
16:59alphazeroWell, -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:02Chousukehmm
17:03rhickeyalphazero: 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:03rhickeyit's not an executable script
17:04Chousukeapparently I can't wget stuff from google code easily :/
17:04rsynnottalphazero: I think -server is far more aggressive about JITing, which may help to explain the extra processor usage
17:04Chousukethe file link takes me to some stupid clickthrough page :P
17:04alphazerorhickey: so how do I run ants.clj? from Repl?
17:04Chousukealphazero: emacs & slime works very well :)
17:05Chousukeyou can eval the entire file and then just eval the code inside the comment separately
17:05alphazeroChousuke: damn it, I'm drawing the line at (((((()))))) .. ;)
17:05rhickeyalphazero: I load it into emacs, then run each line in the comments one by one, for demo
17:06rhickeybut your problem definitely is that it is loading itself infinitely recursively
17:06rhickeyblowing permgen on compilation
17:06alphazerorhickey: well, i'm not setup for that yet. so no way to run this simply from Repl?
17:07Chouseralphazero: yes
17:07Chouserjava -cp clojure.jar clojure.lang.Repl ants.clj
17:07Chouserthen paste each of the lines from the comment section into the repl, one by one
17:08Chousukeyou really should consider using emacs. it's worth it just for slime :P
17:08Chousermiddle-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:09triddellalphazero: if the REPL is already started the first line in the comments is (load-file ...
17:09triddelljust point to your ants.clj
17:09triddellthen run the other lines in comments
17:09alphazeroChouser: 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:12alphazeroHey, success! Thank ya'll for your patience.
17:12ChouserChousuke: I'm glad you find slime worth while. I'll refrain from saying anything else.
17:14Chousukeheh
17:14Chousukewell I can handle editing in emacs with viper :P
17:15Chousukethough I do use some of the less offensive emacs shortcuts too.
17:15Chousukehaving caps lock as control really help
17:15Chousukes
17:17ChouserI 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:17Chouser...when all they really need is their favorite text editor, clojure.jar, and a JVM.
17:17Chouserat least to get started.
17:17Chousukewell, I guess we can start recommending 1.0 after it's out
17:18danm_although, writing lisp in an editor which doesn't speak parens is somewhat frustrating
17:18ChouserChousuke: only if there's a perfectly-matched slime setup for 1.0 available, right?
17:18Chousukewell, there is that clojurebox thing
17:18Chouserfor Windows
17:19Chouser...and still you're going to spend time learning emacs instead of clojure
17:20ChousukeI suppose.
17:20Chousukenow if I could figure out why my aquamacs insists on opening two windows on startup I'd be happy.
17:20hiredmanclojurebot: emacs?
17:20clojurebotbut I like using notepad++!
17:21hiredmanactaully I did a few euler problems in notepad++
17:23gnuvince_You wrote the solution in notepad++ or you actually used notepad++ to solve them?
17:25hiredmana solution using clojure in notepad++
17:25Chousernow, writing notepad++ using a solution in clojure, why that'd be something.
17:26gnuvince_;)
18:12triddellUsing 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:12triddellthis was created: #=(java.util.HashMap. {"key1" "value1", "key2" "value2"})
18:14triddellif this object is represented by *config* how would I access the values, etc.?
18:15rhickeytriddell: 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:15rhickey(map (fn [[k v]] [k v]) #=(java.util.HashMap. {"key1" "value1", "key2" "value2"}))
18:15rhickey(["key1" "value1"] ["key2" "value2"])
18:17rhickeyalso:
18:17rhickeyuser=> (for [[k v] #=(java.util.HashMap. {"key1" "value1", "key2" "value2"})] [k v])
18:17rhickey(["key1" "value1"] ["key2" "value2"])
18:17rhickeyuser=> (keys #=(java.util.HashMap. {"key1" "value1", "key2" "value2"}))
18:17rhickey("key1" "key2")
18:17rhickeyetc
18:18triddellthanks rich!
18:18meredyddIs #= new?
18:18fyuryutriddell: if you want to turn it into a persistent hash map: (into {} your-hashmap)
18:19rhickeymeredydd: don't use #= in your code
18:19fyuryutriddell: less noise on the repl
18:19meredyddYou just used it in a fragment there. What does it do?
18:20triddellfyuryu: I'll try that
18:20rhickeymeredydd: nothing that (java.util.HashMap. {"key1" "value1", "key2" "value2"}) doesn't, I just grabbed it from his output
18:21rhickeyit's a print-dup format for serialization - you won't see them at the repl at all soon
18:23meredyddah...a quick google suggests you're doing something with generic-ising the print functions
19:55clojurebotsvn rev 1173; updated readme with run and build lines
20:04triddellanother 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:06Chouserthe string "context-root" is different from the keyword :context-root
20:07triddellright, I'm trying to understand the "maps of their keys" piece
20:07triddellI mean functions of their keys
20:07Chouseroh, that's just (*YAML-config* "context-root")
20:07phftriddell: functions of their keys should be opposed order
20:07phfwhat Chouser said
20:09triddellah, ok, thanks
20:23rhickeyNew release: http://clojure.googlecode.com/files/clojure_20081217.zip (for your friends that aren't on SVN yet)
20:24Chousukehooray. now the release version will actually work with most of the examples in the wiki and other sources :)
20:24rhickeyI could use some help going over the docs/examples looking for inaccuracies or anachronisms
20:24rhickeye.g. trying every example
20:35qebabHi. 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:36hiredmanof those three it is most like scheme
20:36Chouserqebab: it feels like a fresh sea breeze on a stifling hot day
20:38qebabhiredman: 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:38ChouserClojure does not have haskell-like pattern matching, but it does have handy destructuring.
20:38qebabChouser: 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:39qebabaha, so that's what it is
20:39phfqebab: there's also dispatch on the number of arguments
20:39qebabdoes it work on all datastructures that have builtin syntax?
20:39phfbut i think that's mostly a mapping to java world
20:39Chouserqebab: yes
20:39qebabcool
20:40hiredmanclojure has dispatching on any function of the arguments to a function
20:40Chouserqebab: if you don't mind the format, watch one of the screencasts -- probably the one on sequences
20:40Chouserthat'll get you motivated.
20:40qebabmy first impression is that this is common-lisp with a whole bunch of bad design choices removed, and lots of good ideas added
20:41Chousukethat's not a bad first impression I guess.
20:41Chousukenot optimal either though.
20:41Chouseryeah, it doesn't feel like common lisp to me.
20:42qebabwell, I prefer scheme to common lisp, but find the latter more practical... I'm hoping that clojure will be both practical and nice :)
20:42Chousukethe java interop is perhaps underappreciated. a lot of clojure "Just Works" with java.
20:43qebabyeah, looks like a very nice feature
20:43hiredmanwhich is really nice
20:45qebabthere are tons of cool examples, that's for sure
20:46qebabis there a handy documentation searching function?
20:46Chousuke(doc find-doc)
20:46clojurebotPrints documentation for any var whose documentation or name contains a match for re-string-or-pattern; arglists ([re-string-or-pattern])
20:47qebabsomething like help() without parameters does in python (Let's you search in docstrings and module documentation and things like that)
20:47qebaboh, neat
20:47qebabthanks
20:47Chousukeit's not very easily browseable though.
20:48hiredmanbookmark clojure.org/api
20:48Chousukeit 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:49qebabthis works nicely for now, I'm basically just working out what the functions I'm used to from scheme/cl are called here
20:50Chousukethe wikibook tutorials and tips section has something about that.
20:50Chousukethe book is in pretty bad shape still, but hopefully it will improve :P
20:51hiredmanclojurebot: map?
20:51clojurebotmap is *LAZY*
20:53phfwhich allows for some ... interesting debugging situations in combination with local bindings
20:53qebabohh, map is lazy :o
20:54Chousukeqebab: most of the seq-consuming functions in clojure are
20:54Chousukebe aware of this when dealing with functions that have side-effects :)
20:55qebabChousuke: 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:55Chousuketo avoid mapping #(println "hello" %) over a collection and wondering why it does nothing
20:55qebabgah
20:55qebabI just managed to pour coffee on my desk
20:58RSchulzPouring coffee on your desk is a challenge, so you should feel proud!
20:59hiredmanclojurebot: qebab likes haskell
20:59clojurebotexcusez-moi
20:59hiredmandamn it
21:00hiredmanhmmm
21:00qebabclojurebot: help
21:00clojurebotI don't understand.
21:00qebabwhat can it do?
21:01hiredmanwhat would you say if I told you qebab likes haskell?
21:01hiredmanclojurebot: what would you say if I told you qebab likes haskell?
21:01clojurebotYo 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:01hiredmanqebab: not much
21:01qebabokay
21:02hiredmandoes docs
21:02hiredman(doc trampoline)
21:02clojurebottrampoline 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:02qebabthat's useful
21:03qebaboh, you can optionally name lambdas so they can recurse?
21:03hiredmanyes
21:04hiredman(fn a [x] (a x))
21:04qebabthat's pretty awesome
21:27RSchulzqebab: 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:48triddellwhat's the best way to recode a switch statement in clojure/lisp?
21:48durkalook at cond
21:49triddellgot it, thx
23:00timothypratleyis 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:01Chouser(some #{:c} [:a :b :c :d :e])
23:05timothypratleyah... so
23:05timothypratleyuser=> (some #(= %1 \e) "efg")
23:05timothypratleytrue
23:05timothypratleyuser=> (some #(= %1 \e) "afg")
23:05timothypratleynil
23:05timothypratleythanks
23:07Chouseror (some #{\f} "efg")
23:08timothypratleyeven better!
23:54triddellAnybody here use the html generation features of Compojure?
23:56triddellIt'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:58triddellWould one typically use a for comprehension to process a list of files?
23:59dhayatriddell: side effects are typically done with doseq