#clojure logs

2008-09-30

00:02arohneris there any introspection that can be done on local variables that a macro creates?
00:03arohnerI'm looking at a macro that does (let [foo (func-call)] (your-code))
00:03arohneraside from reading the macro source, is there any way to figure out where foo came from?
00:03arohneri.e. I can't do (meta (var foo)) because it's a local variable
01:04abrooksalbino: Thanks for pointing out Nailgun. A couple of weeks ago I drew up plans to do a similar thing only using Unix domain sockets (on platforms that support it) instead of TCP sockets. Unix domain sockets have some neat features such as being able to actually verify uid/gid over the socket securely and the extra nifty ability to send file descriptors via the socket. (Unix domain sockets are only acessible on the same host.)
01:05abrooksWith the ability to send file descriptors, the IO has zero overhead -- the "remote" process actually uses the same file descriptors directly.
01:07abrooksThere are certain things (process niceness, capabilities (on Linux and others), process quotas, etc.) which cannot be sent across the socket but it's fairly reasonable that one can have near zero startup overhead and truly zero runtime overhead.
11:23blackdoghttp://blogs.azulsystems.com/cliff/2008/09/jvm-language-su.html
11:24blackdogsome good comments from cc - "Clojure spits out bytecodes that look really nice. The purely functional data-structures also look really nice; and the STM scaled surprisingly well. I definitely need to do some coding with it."
11:25rhickeyalso: "I ran Clojure's STM Traveling Salesman Problem using 600 worker 'ants' to optimize the path. It ran straight-up without a hitch, no tweaks - and with great scaling"
11:27blackdogcould be good for the front page of clojure.org
11:27rhickeyhe used that Clojure TSP program to demo his super-cool profiling tools - very neat to see Clojure bouncing 600 lines of his CPU meters
11:28rhickeyIt's still early days in testing STM at these scales, but Cliff's a great resource and very helpful
11:28blackdoga great start! not that i'll ever use a box like that :P
11:28abrooksrhickey: Glad to see you made it home safe! Sorry you were kept there so long. Did you get home before 1am?
11:29rhickeyabrooks: just after - no problem driving, and was happy to stay and talk. Such a great audience!
11:30abrooksI brought five guests and they all loved it!
11:31pjb3Did anyone record the talk last night?
11:31rhickeyMet Dan Weinreb. Gerald Sussman, Alan Bawden. Last week I had Guy Steele in the audience - fun to connect with these guys who started it all
11:32rhickeypjb3: I did a screen+audio capture and someone videotaped
11:32pjb3rhickey: cool
11:33blackdogdid you have any awkward or standout questions last night ?
11:34abrooksrhickey: How did last night the group size rougly the same size audience as previous talks?
11:34abrookser....
11:34rhickeyI think the audience was genuinely interested in understanding Clojure rather than challenging it
11:34abrooksrhickey: How did last night's group size compare with the audience size from previous talks?
11:34leafwrhickey: because clojure is not just an incremental improvement over java.
11:34waltersit seems pretty beyond challenge after looking at it for more than a few seconds, IMO
11:35abrooksleafw: Because Clojure's not an incremental improvement over Lisp...
11:35blackdogi noticed ola bini seemed to feel uncomforatable with clojure's new structures, which prompted my question if the 'old school' were cool
11:35abrooksleafw: This crowd *knows* that Lisp is an improvement over Java. ;-)
11:35leafwabrooks: libraries and legacy code, thye matter a lot.
11:36abrooksleafw: Certainly. One of the many great things about Clojure.
11:36leafwall of a sudden, we can have both.
11:36leafw(lisp and libraries)
11:37rhickeyblackdog: I didn't get to finish my conversation with Ola about that, but I think if he saw how easy it is to handle the data structures uniformly in Clojure he might change his mind: e.g. (into (empty coll) (map f coll)) works for anything in Clojure
11:37abrooksleafw: CL has great libraries but they're have less relevance to the current universe.
11:40rhickeyblackdog: I think the oldest of the old school were perhaps the most receptive - they remember Lisp before standardization when everyone had their own dialect and there was lots of variety and innovation
11:41blackdogfantastic, you hit a sweet spot for sure,
11:42rhickeyI had so much fun - this was the audience best suited to 'getting' Clojure right away, as they already 'got' Lisp and I could presume that in my talk
11:45Chouserdef-aset generates calls to Array static methods like setLong. Would it be acceptible for it to call RT.aset instead?
11:47rhickeyabrooks: crowd was smaller than JVM languages summit, larger than the Java user group I did in June
11:48abrooksOh, I wasn't really counting the JVM languages summit. Those folks weren't there just for Clojure. In 2010 they will be. :-)
11:49rhickeyabrooks: It was the biggest user group so far
11:50abrooksGreat. I heard it was over sixty. Thirty-five had registered.
11:51waltersi wonder whether that large group that came in after 6pm was together in some way, like all from some class
11:57danlarkinoooo I can't wait for a new video
12:03earthvssouphere here
12:05rhickeyIt's over 3 hours...
12:06rhickeyactually there were lots of good questions, if they came out in the audio it will be great
12:07danlarkinfantastic
12:16earthvssoupHeck, I'd watch 3-hours just to see the Emacs-Fu. ;)
12:20leafw[rhickey: I make it customary to repeat the questions, so everybody hears them through the microphone]
12:36rhickeyleafw: yes, I keep telling myself to do that, but then forgetting...
12:47Chouserlooks like JavaScript may be growing thread support after all: http://www.whatwg.org/specs/web-workers/current-work/
12:48Chousermessage passing for inter-thread communication
12:48rhickeysaw that
12:49rhickeyI don't think they could support actual data sharing giving JS heritage, so offering an explicit API gets around that
12:49Chouserright
12:51rhickeyA Boston Lisp Meeting report: http://xach.livejournal.com/#entry_191581
12:53ChouserI've been getting reports all morning from my half-dozen friends that were there.
12:53Chousereveryone enjoyed it
12:53danlarkinhttp://search.twitter.com/search?q=clojure lots of positive experiences on twitter too
12:54earthvssoup@Chouser. Thanks for the tips on my On Lisp -> Clojure project. Much appreciated.
12:54baetis-flyanyone know if a video exists of the boston lisp presentation on clojure exists?
12:54Chouserearthvssoup: sure, looks like a cool project.
12:55earthvssoupThanks. That remains to be seen. ;)
12:55Chouserbaetis-fly: nothing online yet, but there's hope.
12:56rhickeyearthvssoup: yes, good project. You should try to stay functional when possible, rather than copying imperative things from CL, that will have the most value. Stuart Halloway has been doing the same (translating to FP style) in covering the PCL stuff, with much success
12:58earthvssouprhickey: I am still trying to find my way out of my imperative nature. It's slow going for the first couple of chapters, but I'm confident that I'll come around.
13:02danlarkinearthvssoup: it's always helped me to think "what do I want" rather than "how do I get it"
13:55earthvssoupdanlarkin: Thanks, I will keep that in mind.
17:08StartsWithKif i have macro like (doto x (something1 args) (something2 args)), i would like to (find-var something1) and (find-var something2) and if something exists and is macro, evoluate it in a same way (clojure/doto) evoluates first argument before it includes it in rest of the macro
17:08StartsWithKis something like this possible?
17:18hoeckStartsWithK: so you want a macro that treats other macros specially?
17:19StartsWithKsomething like that
17:19hoeckStartsWithK: or do you just want to expand nestet macros?
17:19StartsWithKhmm
17:19StartsWithKexpand i think
17:19StartsWithKif that is right term
17:19StartsWithKok, one 'example'
17:20hoeckthe thing that `macroexpand' does
17:20StartsWithK(doto (JButton.) (on :action-performed (fn [e] (println "you clicked on button"))))
17:20StartsWithKthis is what i will put on firs version
17:20StartsWithKwhere (on) is some sort of 'patch' multimetod that my doto macro will use
17:21hoeckah, i see
17:21StartsWithKbut what i wan is (doto (JButton.) (on :action-performed [e] (println "you clicked..")))
17:22StartsWithKso, on must be a macro in second example and it should expand to firs example before i use it in
17:22StartsWithKactualy :action-performed is defalut so it will be even shorter as (on [e] ...)
17:23hoeckso you want to roll your own doto macro?
17:23StartsWithKyes
17:24StartsWithKi mean, i have one now
17:24StartsWithKthis is my idea of 'patch' system that i would like to include in it
17:24ChouserI think you could approach two ways -- either make "on" a global macro of its own, or have doto walk through its args looking for (on ...)
17:25Chouseractually, this first won't work. so you could try the second. ;-)
17:25StartsWithKChouser: i was thinking i would lookup for var, and see does it have macro metadata on it
17:26StartsWithKor maybe on some metadata of my own like :dotoexpand true
17:27Chouser(meta (resolve foo)) where foo is a local that contains the symbol you're examining
17:27StartsWithKi pasted this yesterday http://pastebin.com/d3bb8978
17:27StartsWithKat the end is example of extended doto for now
17:28StartsWithKnow what i want are two more things, first is that all (method args) are routed to (defmulti patch) that will first try to find multimethod for given class with given method name and execute it instead of classes method
17:29StartsWithKand second thing are the macros inside doto as i described them now
17:29ChouserI think "resolve" is what you're looking for to find the var for a symbol
17:30Chouser(:macro (meta (resolve f))), like you have (keyword? f)
17:31StartsWithKyes that is what i need
17:32StartsWithKbut, how will i expand it
17:32StartsWithKthat part bugs me even more
17:34Chouseryou probably don't want to expand it yourself, but rather drop it into your output, where it can be expanded for you by the compiler
17:34Chouserif your macro produces (do .... (foo ...) ...), and foo is a macro, it'll get expanded for you
17:36StartsWithKwhen i process doto args, i will in the end transform (doto x (meth1 a) (meth2 b)) to something lik (. x meth1 a) (. x meth2 b)
17:36StartsWithKbut if i don't expand on macro ill get (. x on ...)
17:37Chouserright, so don't do that.
17:37ChouserWhen you identify it as a macro, produce (on x ...) instead of (. x on ...)
17:37StartsWithKoh, i see
17:37StartsWithKyes
17:38StartsWithKi wasn't thinking i can just expand it in different way :)
17:39Chouseryou know, I don't really like how doto has you specify methods without any .
17:39Chouseryou could make a pretty simple macro that worked instead like (doto obj (.meth1 a) (.meth2 b))
17:40Chouserthen you wouldn't have to do any special handling to get macros or even regular functions in there
17:40Chouser(doto obj (.meth1 a) (on foo) (.meth2 b))
17:40Chouserthe doto macro would just insert obj as the 1st arg of each, and either get a method call, or a macro, or whatever.
17:41Chouserkinda like -> except for all applying to one thing instead of chaining.
17:42StartsWithKtrue, that would be much easyer way to do it
17:42StartsWithKbut then i wouldn't be compatible with clojure/doto
17:43ChouserI actually think it'd be easier to read than clojure/doto
17:43Chouseryeah, good point. you might choose to name it differently
17:43Chouseror talk rhickey into accepting your syntax instead. :-)
17:43StartsWithK:)
17:44StartsWithKi will bug him when this monster is finished :)
17:45StartsWithKi would like at least something like (method+) syntax
17:45StartsWithKi find i do a lot of (addOption ..) (addOption ..) ...
17:48Chouser(with-arg foo (a) (b)) --> (do (a foo) (b foo))
17:48Chouser(with-cmd .foo (a) (b)) --> (do (.foo a) (.foo b))
17:49Chousereach would be simple and together would buy you doto and method+ functionality.
17:52StartsWithKlet me sketch something bigger to demonstrate
17:53H4nshi - i'm new to clozure. what is a [B@4a5afcb1 (something binary i guess) and how can i decode that into a string, possibly specifying the character set?
17:53H4nsclojure
17:54danlarkinH4ns: how did you get it?
17:54H4nsdanlarkin: i got it from the http client.
17:54rhickey[B is a byte array
17:56danlarkinmaybe run seq on it?
17:56StartsWithKChouser: http://pastebin.com/d5b2bdf6e
17:56rhickeyString has a ctor from byte array, so (String. ba)
17:56rhickeyoptional second arg is a string naming a charset
17:56rhickey(String. ba charset-name)
17:56H4nsrhickey: very cute, thanks! i've seen your talk yesterday, coming from cl.
17:57rhickeyH4ns: cool - do you know Java?
17:58H4nsrhickey: only a tiny bit, i'm mostly common lisp, coming from perl, c++, c
17:58rhickeyyou might want to bookmark: http://java.sun.com/j2se/1.5.0/docs/api/ then
17:59H4nsrhickey: but i've written applets and small applications, so i'll find my way through. i'll just have to adopt to the notion that many primitive things are just java apis.
17:59H4nsrhickey: bookmarked, thanks
17:59rhickeyH4ns: ok - I'm sure you'll get up to speed in no time, lots of helpful folks here and on the google group too
18:00H4nsrhickey: ok - thanks again for the warm welcome. yesterday morning i had no hope for lisp, that has changed a little now :)
18:02H4nswhere do i find clojure.xml?
18:04H4nsahj.
18:04H4nsnever mind.
18:04ppjtHi all; I'm playing with, & have aped successfully for use in macros, the `(let ~'[i 5] ...) form -- i.e. the ~', quote-unquote part -- but don't think I could explain it if I had to. I see that without it the variable, say, in the let binding above would be qualified with a namespace, but I'm still not exactly sure why.
18:05ppjtDoes anyone mind explaining?
18:06ppjt[unquote-quote, that is]
18:08H4nshm. (clojure.xml/parse "http://planet.lisp.org/rss20.xml") seems to end up in an unhandled exception when the server closes the connection. expected? better to slurp using the http client (which works) and then create a stream from that?
18:11danlarkinH4ns: (clojure.xml/parse "http://planet.lisp.org/rss20.xml") works for me
18:13H4nsdanlarkin: i'm ending up in the slime debugger, (condition-case (error (slime-net-read ... - slime fairly recent, clojure from cvs, java 1.5 downloaded today
18:13H4nsi'll try without slime
18:13ppjtMe too; what's the exception you get, H4ns? A java.net.something-or-other?
18:14H4nsif i interpret the message correctly, it is actually slime that fails, no java in there, but a net-read-error. i'll try without first.
18:14H4nsyes, slime problem. is slime not really the way to go? what do others here use?
18:15H4nsmight also be related to the fact that i'm using windows. if that is uncommon, i'll use something else.
18:16ppjtI'm not an emacser, but I believe someone has worked up a slime-like thing called swank-clojure. Just a sec...
18:16H4nsppjt: that is what i use.
18:17H4nsppjt: i've downloaded it fresh from git
18:17fyuryuI use clojure-mode for emacs, no problems so far
18:17danlarkinH4ns: slime is what rhickey uses too I believe
18:17H4nsfyuryu: how do you evaluate? just the bare repl in a inferior shell and copy and paste?
18:18ppjtYeah, I think a lot of folks are having success w/ swank-clojure
18:18fyuryuH4ns: no, there are kb combos for that
18:18fyuryuH4ns: for sending code to the repl, that is
18:19H4nsokay, maybe windows is the culprit. i'll move to unix, thanks so far. the parsing and http clienting looks very nice, so i'll spend some time to get my environment straight :)
18:19fyuryuH4ns: i'm on windows too
18:20danlarkincould it be that code in H4ns' pull of swank-clojure has a bug and fyuryu's does not?
18:21H4nsdanlarkin: could also be that my slime/emacs is not the right version.
18:21fyuryudanlarkin: I don't use swank-clojure, just clojure-mode
18:22danlarkinah
18:29H4nsthanks so far. seems i need to tweak some more, bbl.
18:31ppjtAnyone familiar with the `(let ~'[i 5] i) -- i.e. the ~' part -- trick?
18:35hoeckppjt: its to avoid the `i' becoming a namespace-qualified symbol
18:36ppjthoeck: Do you know how it does that, exactly?
18:40hoeckit evaluates the quoted symbol and inserts that result into the macroexpansion
18:43hoeckthe ~ means to evaluate the following expression
18:43hoeckand in case of `'foo, the following expr is 'foo
18:44hoeckevaluating to foo
18:44ppjthoeck: why doesn't the resulting symbol, then, get namespace-qualified?
18:45hoeckcause its evalutated at the expansion time of the macro
18:45ppjtI think that's where I'm dropping out -- when does namespace-qualification happen in normal evaluation, & why wouldn't this symbol be subject to same?
18:46hoecknamespace-qualification happens only in backquote as far as i know
18:46StartsWithKhoeck, Chouser, thanks for help
18:47ppjthoeck That makes sense, based on my REPL experiments...
18:48hoeckyeah, just try `(foo bar), `(foo ~'bar) and (let [bar [1 2]] `(foo ~bar))
18:49ppjtSo, though everything inside a backquoted expression is _quoted_, the quote-unquote extra bit serves to avoid the ns-qualification stuff that comes as well w/ backquoting
18:51hoeckactually, its an unquote-quote :)
18:51ppjtRight!
18:53ppjtThough it makes more sense to think of the act of quoting, then unquoting that quote -- in right-to-left evaluation order that lisp works in...
18:53ppjtAt least makes more sense to me
18:54ppjthoeck: Do you know the utility of backquote's namespace-qualifying?
18:57hoeckwhen you define a macro in namespace a and expand it in namespace b, it avoids that the expanded expression does shadow symbols in namespace b
18:58ppjtRight -- makes good sense
18:59hoeckwithout this you would need to manually namespace-qualify each symbol
18:59hoeckor hope that no shadowing occurs
18:59ppjtYeah -- would make for either tedious or bug-laden code
19:00hoeckright
19:00ppjtSo is the quote-unquote (or vice-versa) technique the standard way to, say, set up let bindings inside of a backquoted expression in a macro?
19:00ppjtOr are there others?
19:01hoecki guess its the only one
19:02ppjtI don't have time to look through boot.clj at the moment, but that'd be the place to investigate; I'll do so tonight...
19:02hoeckbut you can build lists directly with (list 'let (vector 'i 5) ...)
19:03ppjtOh yeah, good point
19:03ppjtThough, cause of lost readability there, I'd gladly take the ~' option
19:04H4nscan anyone here confirm that slime works on windows? i'd like to know that i'm not aiming for something too exotic
19:04hoeckbackquote is basically an abbreviation, like quote '
19:05ppjtWith the semantics of ', plus the ability to use ~, right?
19:06hoeckH4ns: i have a windows box at work, but I'm only using ilisp, not slime, could investigate tomorrow
19:06H4nshoeck: so there is an ilisp backend? i would consider that, too.
19:08hoeckppjt: yes, basically, + X times magic like doing namespace-qualif. in clojure and other things I don't know in cl
19:08shooverH4ns: yes, I use swank-clojure on a couple Windows machines. Make sure you have recent slime from CVS, at least from this month
19:09H4nsshoover: ah, thank you - any special emacs version, or stock windows emacs 22?
19:10hoeckH4ns: i build this one myself, but i want to use slime soon too, on windows and linux
19:11H4nshoeck: ok - i'll first try an updated slime and then try ilisp if i fail. thanks!
19:11ppjthoeck: An alternative to ~' in backquoted let expressions: `(let [i# 5] i#)
19:11ppjtAnother bit of ` magic, it seems
19:11shooverH4ns: works with stock 22.2 and latest patched emacs 23 from http://ourcomments.org/cgi-bin/emacsw32-dl-latest.pl
19:16H4nsshoover: thanks, updating slime fixed my problem.
19:16ppjthoeck: Gotta run -- thanks
19:16hoeckppjt: np
19:44H4nswhat ways to process xml are popular in clojure? i've looked at clojure.xml and cxml and there is java's facilities. i need something that lets me extracts elements out of a dom easily, preferably using an xpath/sxpath like syntax to specify what elements interest me
20:21rhickeyH4ns: Chouser has an xpath-like library in clojure-contrib https://sourceforge.net/projects/clojure-contrib called zip-filter
20:22rhickeyvideo from last night converting right now
20:23H4nsrhickey: i've also read what you wrote about 'xml is just data', trying to bend my head around that. i'll look at zip-filter, thanks.
20:33H4nswhat is the proper way to quit clojure?
20:35rhickeyH4ns: (System/exit 0)
20:36H4ns*bow*
21:13danlarkinrhickey: will you upload it to blip this evening?
21:23rhickeydanlarkin: no, tomorrow, conversion to Flash takes over 8 hours
21:24danlarkinrhickey: I suppose I can wait that long...
22:05acharlton?
22:09acharltonHi, all. Is there any reason why a piece of code would run differently in the repl than straight from the command line (ie. clojure.lang.Script)?
22:12rhickeyacharlton: run differently in what way?
22:17acharltonI have a ref that is a map that holds other maps. As far as I can tell, when I run my program through clojure.lang.Script it adds an extra, duplicate map to that ref. This does not happen in the REPL.
22:22acharltonThat's not really the whole story, since there are some functions manipulating the ref that seem to be creating the duplicate, but why would it only be happening with clojure.lang.Script?
22:26Chouseryou run the same .clj file, the only difference being the class you name on the java command-line?
22:26acharltonThat's right.
22:29acharltonWell, I suppose I haven't actually run the file through java command-line for the REPL instance. I've started the REPL and then (load-file "thesamefile.clj")
22:29Chouserhm.
22:34acharltonHuh. I just tried loading the file with the java clojure.lang.Repl, and the thing that happened with clojure.lang.Script happened again. It only seems to work properly (in the way I intended it - my code may very well be faulty) when I start the actual REPL and (load-file)
22:39Chouseryou could paste your code, if you want.
22:54acharltonI'm not sure if it's worth the trouble. My code is actually broken (upon further inspection), and it's quite convoluted. I was just a little freaked out that it runs differently from inside the REPL.
23:12acharltonAlright. There was no mysterious map duplication. It was an accidental byproduct of a function. I'm still a little curious about why the results would differ inside and out of the REPL, though. Any insight?
23:13acharltonOr was it a freak of nature?
23:14rhickeythere should be no difference, unless prior to load-file in the repl you manually set up some environment not present when run as a script
23:17acharltonI'm afraid not. (load-file) was the one and only command run in the repl.
23:19rhickeyacharlton: Script just calls loadfile, so it shouldn't be different
23:20acharltonThat's messed up, then.
23:20rhickeybut if you can reproduce I'll chase it
23:33acharltonWell, it doesn't seem to affect me in any real way, and it does seem to be a weird fringe case. I'm not even sure if the ref itself was differet, I was just basing my assumptions off of the visual feedback of my program.
23:35rhickeyif you see it again, grab it by the tail
23:36acharltonHeh. Alright.
23:36acharltonThanks a lot for the help. Have a good night.