#clojure logs

2008-10-22

00:00lukegoso I want the repl and my Emacs buffers to be in the scope of a common binding. doable? alternative?
00:00arohner(binding [foo 2] ...)
00:00arohneryou might be able to use a ref
00:00lukegoI want to write a series of commands at the prompt that will each update the value of this var. so it won't do to wrap each in a separate binding
00:00arohner(def foo (ref 1))
00:00arohnerthen to read it, @foo
00:01arohnerthough I'm slightly confused by emacs buffers being inside the scope of anything clojure
00:02lukegoI mean slime commands in emacs buffers
00:02lukegothe slime support is pretty impressive btw kudos to the author
00:05lukegorepeatedly calling def seems to work too..
00:06arohneroh, so you want the repl and the slime thread to share the same scope
00:06arohner(I know almost nothing about slime or clojure-swank btw)
00:06arohnerbut yeah, sounds like you need a ref then
00:06arohneror an agent
00:06arohneryeah, that will work but rhickey has called it bad style to use that for anything except for C-c C-l
00:08lukegowell to start with its nice that the bad style works. I'd rather make something run now and improve style later than bang my head on IllegalThreadStateExceptions
00:08arohnerdefinitely
00:09arohnerwhat are you working on?
00:09lukegosame as this http://mitpress.mit.edu/sicp/full-text/sicp/book/node64.html
00:12lukegowow even M-. works! I'm very impressed with swank-clojure :)
00:13arohnerpartial is faster and better than returning a new fn, right?
00:18danlarkinarohner: how is partial implemented? I'm guessing it just returns a function itself...
00:19arohnerdanlarkin: yup. you're right
00:19arohner(fn [] ... (apply ...))
00:25alvin-xare there any known problems with (format)? I'm using clojure_20080916 and using (format "%10s: %s\n" "a" "b") for example gives me "java.lang.Exception: Unable to resolve symbol: format in this context"
00:28danlarkinalvin-x: can you do #'format in your REPL?
00:30lukego(symbol "foo" (create-ns 'myns)) faileth - why?
00:31alvin-xdanlarkin: you want me to just run "#format (sorry, _very_ new to clojure and not familiar at all with reader-related stuff)
00:33danlarkinalvin-x: yup
00:33danlarkindoes that throw an exception?
00:33alvin-xyep, No dispatch macro for: f
00:34alvin-xjava.lang.Exception: Unable to resolve symbol: ormat in this context
00:34danlarkinoh, single quote, sorry
00:34danlarkinnot double
00:34danlarkin#'format
00:34alvin-xdidn't see the quote there :)
00:35alvin-xjava.lang.Exception: Unable to resolve var: format in this context
00:36danlarkinalvin-x: time to update your checkout :-D
00:36alvin-x(. String format "%d" 1) gives java.lang.ClassCastException
00:36alvin-xsvn time...
00:43danlarkin(. String format "%d" 1) doesn't work because it isn't the right syntax... it'd have to be (. String (format "%d" 1)) or (String/format "%d" 1) -- but that doesn't work because String doesn't have a format static method? (http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html says it does, so I'm slightly confused now TBH)
00:45alvin-xi'm getting the same behaviour from svn trunk
00:46danlarkinso #'format still bonkers out for you?
00:46alvin-xaha... java.lang.Exception: Unable to resolve var: format in this context
00:47arohnerwhat ns are you in?
00:47arohneruser=> (format "%10s: %s\n" "a" "b")
00:47arohner" a: b\n"
00:48arohneryour example worked perfectly on my box, running svn trunk
00:48alvin-xarohner: how do i find it out the current ns?
00:48danlarkinarohner: his ns shouldn't matter, clojure builtins are automatically injected into every ns
00:49arohnerdanlarkin: not every ns. there are a couple of ways around it, like (in-ns)
00:49arohneralvin-x: the prompt should tell you
00:49arohneri.e.
00:49arohneruser=>
00:49alvin-xarohner: ok, i'm in the user ns
00:50arohnerdanlarkin: user=> format
00:50arohner#=(clojure.format__1709. "clojure.format__1709@8f57d2")
00:50arohneruser=> (in-ns 'bogus)
00:50arohner#=(find-ns bogus)
00:50arohnerbogus=> format
00:50arohnerjava.lang.Exception: Unable to resolve symbol: format in this context (NO_SOURCE_FILE:0)
00:50arohneralvin-x: try typing clojure/format
00:51arohnerwhat does that print?
00:52alvin-xNo such var: clojure/format
00:52arohnerok, that's weird
00:53alvin-xbrb
00:53arohnertry something that is obviously built in, like clojure/print
00:54danlarkinarohner: neat trick! does clojure/ns do that symbol insertion?
00:54alvin-xuser error :) i had an old clojure.jar stuck in the JRE's lib/ext dir :)
00:54alvin-xsorry guys
00:55arohneralvin-x: np
00:55arohnerdanlarkin: what do you mean by symbol insertion?
00:55arohnerclojure/print just refers to the function print in the clojure namespace
00:55danlarkinarohner: sorry, I mean that #'format resolves to #'clojure/format no-matter what namespace I'm in
00:57arohneryes, clojure/format means look in the clojure ns for that symbol, regardless of what ns I'm in
00:58danlarkinarohner: yes I know... but why does #'format resolve to #'clojure/format when I switch namespaces with (ns foo) but not with (in-ns 'foo)?
00:59arohneroh, because ns was created to be used at the top of a file as a convenience
00:59arohnermost everyone was doing (create-ns 'foo) (in-ns 'foo) (refer 'clojure)
01:00arohnerso ns includes the call to (refer 'clojure)
01:01danlarkinah
01:01danlarkinthere we go
01:02danlarkinthanks
01:35rk98x03Morning gents
01:48Lau_of_DKWhen someone does something like (use 'clojure.contrib.lazy-seqs), where do I have to put lazy-seq.clj for the reader to be able to get it ?
01:50danlarkinin your classpath
01:51Lau_of_DKfor class pass I specificalyl call java -cp clojure.jar
01:52parth_mLau_of_DK: put clojure-contrib.jar in your CLASSPATH.
01:53Lau_of_DKoh, there's a jar... where do I get it ?
01:53parth_monce you get the sources for clojure-contrib. run ant. that should create the jar.
01:53Lau_of_DKargh ,Im setting here on a lousy windows machine, no ant or anything
01:53parth_mOh.
01:54parth_mI use linux. Maybe someone has created a pre-built jar ..
01:55parth_mOne option would be to install ant if thats possible.
01:57Lau_of_DKIts not, unfortunately I'll have to wait till I get home
01:57Lau_of_DKThats what you get, for coming to work unprepared :)
02:00larrytheliquidim having trouble getting slime/clojure working, anyone know why this might be happening? http://paste.lisp.org/display/68974
02:04Lau_of_DKLooks like your on windows?
02:05larrytheliquidnope, osx
02:06Lau_of_DKoh
02:06Lau_of_DKAre you sure that ~/ is accepted ?
02:07larrytheliquidhm, i know it is for add-to-list, but maybe not the jar path... let's try it...
02:08larrytheliquidLau_of_DK: wow, that was it... thanks :)
02:08Lau_of_DKno probs :)
02:59jdzi use (add-to-list 'load-path (expand-file-name "~/elisp/swank-clojure"))
03:30Lau_of_DKAchim - I regret to inform you, that I was unable to run your code, although it looked intruiqing
03:31Lau_of_DKFirstly - I lack clojure-contrib.jar - Can you upload it somewhere so that I can get it? Secondly, just pasting the functions into the .clj still throws an exception, not enough args to fn
03:34achim_pLau_of_DK: oh! i'll have a look at it
03:34achim_pre: contrib - you don't need a jar
03:34Lau_of_DKthen what do I need?
03:35Lau_of_DK(use 'clojure.contrib.lazy-seqs) throws a cannot find /clojure/contrib...clj error
03:35achim_phave you got svn at hand?
03:35Lau_of_DKno, Im at work, so pretty handicapped
03:36achim_pah, never mind. here's a zipped version: http://www.bitbucket.org/shoover/clojure-contrib-mirror/get/41bc3ee83e28.zip
03:36achim_pthen do (add-classpath "file:///path/to/src/")
03:38achim_p(after unzipping, of course)
03:40Lau_of_DKThank you sir
03:41achim_pah, stupid mistake. added the "(primerange ..." in the last form without testing it. changing it to "(apply primerange" should work. sorry
03:43Lau_of_DKI extracted what you sent me to p:\clojure-contrib\
03:43Lau_of_DK(add-classpath "file://p:\\clojure-contrib\\")
03:43Lau_of_DKjava.io.FileNotFoundException: Could not locate Clojure resource on classpath: clojure/contrib/lazy_seqs/lazy_seqs.clj
03:44achim_pyour classpath has to point to the "src" dir
03:47achim_pLau_of_DK: i haven't got access to a windows machine - you're sure mixing slashes and backlashes in URLs is the right thing?
03:47Lau_of_DKNo, working on it
03:51Lau_of_DKIve tried every combo in the book
03:51Lau_of_DKit still throws
03:51Lau_of_DKjava.io.FileNotFoundException: Could not locate Clojure resource on classpath: clojure/contrib/lazy_seqs/lazy_seqs.clj
03:55parth_mLau_of_DK: You could verify your classpath using (seq (.. clojure.lang.RT baseLoader getURLs))
03:56Lau_of_DKgreat tip parth
03:57Lau_of_DK(where do you guys get all this stuff?
03:57Lau_of_DKAnyway, the class-path is correct, it points to where it should
03:57parth_mI got this tip from rhickey on IRC some time back :)
03:57Lau_of_DKwait
03:58Lau_of_DKI removed (use 'clojure-contrib.lazy_seqs), and then it worked perfectly
03:58Lau_of_DKw00t?
03:59Lau_of_DKachim, thats some pretty amazing code
03:59Lau_of_DKfinds a hit in less than 5 secs
04:00hoeckLau_of_DK: isn't it clojure.contrib.lazy_seqs?
04:00Lau_of_DKyes, thats what I had, I just got lazy typing it
04:00hoeckoh ok
04:04Lau_of_DKless than 1 second
04:04Lau_of_DKthats pretty god
04:04Lau_of_DKgood
04:04Lau_of_DKI left mine running over night, and it had come up to 9521, target was 997651
04:08achim_p_Lau_of_DK: weird ... glad it's working now
04:23Lau_of_DKMe too - Would you mind putting the algorithm into english for me? :P
04:35Lau_of_DKOh and achim_p_ did you notice that if you click onto a page on the euler wiki, youve got 4 tabs on top, page, discussion, history and notify
04:35Lau_of_DKIf you click the little arrow on "page" you can probably choose delete
04:36Lau_of_DKfor me its grayed out, but if you can, please delete all single and double digit posts, Ive copied them into new holders with new names
04:36achim_p_Lau_of_DK: ok, i'll try it in a minute
04:37achim_p_Lau_of_DK: first it calculates a sequence of accumulated prime sums and puts it in a vector, thus the sum of a range of primes is easily computed by calculating upper-primesum minus lower-primesum - no need to iterate the range of primes for that
04:38achim_p_find-range-for tries to find a range that sums up to a given n. it starts with the first prime, then expands the range (to the right) as much as it can, stops when the sum exceeds n. then it contracts (from the left) as much as it has to. plus: it'll never drop below a range size of minlen
04:38achim_p_the loop works down the range of primes, trying to find ranges, adjusting minlen, so it'll never look for anything shorter than already found.
04:40Lau_of_DKoh
04:40Lau_of_DKthats pretty impressive that you can up with that, thanks a million, quite an eye-opener in terms of producing an effecient algo
04:48achim_p_Lau_of_DK: you're welcome! project euler might be fun after all. :)
04:48achim_p_there were in the order of 1 000 000 000 000 subsequences to consider, so brute forcing would have taken ages
05:08Lau_of_DKTell me about it :)
05:39jdzdoes anybody have a clue how to speed up clojure.xml/parse? or at least meke it use more of the CPU?
05:48Lau_of_DKis it reading directly from a file ?
05:56jdzyes
05:56jdzbut it feels like it has a sleep method somewhere in the loop...
05:58cgrandjdz: is a doctype specified in your xml? The parser may be downloading the DTD
05:59jdzcgrand: oh, that might be the case.
05:59jdzoff to read some SAX Java docs on how to disable it
06:29Lau_of_DKIf you cant work it out, check out the string that xml/emit shoots out first. Maybe you can just inject it ?
06:31jdzhuh? i'm parsing XML files, not generating them.
06:33Lau_of_DKI know, but you need xml/parse to avoid downloading right? So you can do that by injecting xml-id before the actual file
06:35jdzxml-id?
06:57Lau_of_DKdoctype - i might be way off )
07:02alvin-xif I run the (incomplete) snippet here: http://paste.lisp.org/display/68988 in clojure.lang.Repl, it runs fine; but if I run it with clojure.lang.Script, it seems to fall through and just returns me to the OS prompt...
07:03alvin-xwhat should I do to get clojure.lang.Script to run it...?
07:05achim_p_alvin-x: for constructs a lazy seq, if you don't use it, it'll never get constructed
07:05achim_p_the repl prints it, so it gets constructed there. try wrapping it in doall
07:08alvin-xdoes (for [domain (doall (take 10 (cycle domains)))] look ok?
07:10alvin-xno, (doall (for
07:10achim_p_no, i meant (doall (for ...))
07:11achim_p_yes :)
07:11alvin-xthanks :)
07:12alvin-xis there a better way to do this? my goals is to cycle through parameters a number of times and print out some values...
07:15achim_p_doseq maybe? but it doesn't make much of a difference ...
07:16alvin-xhm, when the (prn) is there (as in the example i paster) it works as intended. but i I take it out (so no IO statements in the immediate expression, but only stuck away in print-stcms-info), for seems to wait until all iterations are finished, and prints out all values at once!
07:17alvin-xpasted*
07:17alvin-xbuffering...
07:18alvin-xno matter, i'll switch to log4j
07:18achim_p_mhh, what does print-stcms-info do?
07:18achim_p_ok
07:31alvin-xwish there was a way to trace and step into/over forms in the repl... IMHO that would be better that littering the code with log4j trace calls...
07:35blackdoghttp://www.lispcast.com/drupal/node/77
07:36alvin-xachim_p_: for my use (doseq is better than (doall (for :) thanks for pointing me there.
07:37rhickeyalvin-x: step debugging is available via Java debuggers
07:45alvin-xrhickey: just tried that with jSwat; very nice
07:45rhickeyalvin-x: cool
07:46achim_p_are there any java debuggers that can handle clj files and work with java 1.5? i saw jswat recommended, but it needs 1.6
07:47rhickeyThere was an older version of JSwat that (still) works with 1.5
07:51alvin-xsoon i'll be running clojure on AIX, with the J9 VM :D
07:51achim_p_rhickey: ah, got it. thanks!
07:57milanmitrovichello
07:58milanmitrovicdoes clojure support continuations?
07:58rhickeymilanmitrovic: no
07:59milanmitroviccan it?
08:00milanmitrovicwas that a design decision, or because of compatibility with java?
08:00Lau_of_DKmilan, theres a good discussion about that in the google group actually
08:01milanmitrovicthanks, i'll look it up
08:03rhickeymilanmitrovic: the short of it is - Clojure remains call-compatible with Java, esp in its use of the stack. Continutations would require a totally independent notion of the stack. It does this both for speed and interoperability. Continuations are on the speculative feature list for a future JVM, and if they are added there, Clojure will get them.
08:05rhickeyI think the Fortress folks want continuations, and probably have more pull at Sun then Clojure, at the moment.
08:06rhickeyOTOH, if folks are driven for tail call optimization or continuations, you can lend a hand in the incubator for these things, the Da Vinci Machine multilanguage VM: http://openjdk.java.net/projects/mlvm/
08:11gnuvinceNice: "Rich Hickey presented his programming language, Clojure. This was the talk of the day."
08:12gnuvinceFrom http://www.lispcast.com/drupal/node/77
08:13arbschtI just read that, very encouraging
08:14arbschtcongratulations, again, rhickey :)
08:15rhickeyarbscht: thanks. I really appreciate their including Clojure at Lisp50, it was a great opportunity to connect it with the rest of Lisp
08:15blackdog"the torch was passed" good quote :)
08:16milanmitrovic_rhickey: thanks for the answer
08:18arbschtrhickey: did you get a chance to compare contextl with clojure at any point? I'm curious what you and pascal might think of both systems
08:19arbschtin particular, clojure's dynamic bindings, that is
08:19rhickeyPascal and I never got a moment to have a good discussion at OOPSLA, although we had at ECOOP.
08:20rhickeyDynamic bindings let you do context-like things, but ContextL is bound up in the CLOS model
08:20rhickeyContextL definitely lets you do more, but I personally wouldn't want to do some of the things it enables
08:22arbschtI see. what are some of those things?
08:23rhickeyadding fields in dynamic contexts, morphing types in order to morph behavior
08:23arbschtright
08:24rhickeyClojure's a la carte hierarchies and ability to dispatch on attributes or metadata free you from having to tie these things to classes
08:28arbschtI find one pattern turning up often in my clojure code, which is dispatching multimethods on a dynamically bound var. I think it could be factored out a little into a subset of a contextl-like api, but I don't know if it's worth going down that road yet
08:32Lau_of_DKIs it possible for me to make something like $"25" -> 25 in Clojure? So that I dont have to call (Integer/parseInt (str %)) every time?
08:34rhickeyLau_of_DK: why not just make a helper function?
08:34rhickey(str->int "25")
08:35Lau_of_DKFirstly because I'd just like to know all the specifics of clojure and customizing it. I think lots of code can be made more readable with those types of conversions.
08:35Lau_of_DKSecondly. What you propose would work of course, just takes up more space
08:35asbjxrnI'm trying to attach to my clojure process with jswat. But when I attach jswat becomes unresponsive.
08:36rhickeyLau_of_DK: but reader macros don't compose - you want to use $ for one thing and someone else wants to for another
08:37tWipI don't think $ has any intrinsic meaning to anyone else reading your code
08:37rhickeyIn real CL programs reader macros are rarely used, for that reason
08:38ChousukeIf you're worried about having to type too much, you just need proper completion for your editor.
08:38rhickeyso right now, they ar eall reserved by Clojure, so everyone will share
08:38Lau_of_DKOk Rich.
08:38Lau_of_DKChousuke, yes, tab-completion isnt quite working in emacs/clojure-mode yet
08:38H4nsLau_of_DK: M-/ ftw
08:39rhickeyH4ns: agreed
08:39alvin-xcool
08:40ChousukeI can't even figure out how to type that with my finnish macintosh laptop keyboard layout :P
08:40rhickeyChousuke: option-/ ?
08:41Chousukeon this thing / is shift-7 and alt-shift-7 becomes \ :/
08:41rhickeyyikes
08:41tWipyeah the finnish mac keyboard layout is very poor for most coding
08:43asbjxrnChousuke: set up english as an additional input language, and you can switch to that when coding
08:43Chousukeperhaps I should.
08:45asbjxrnWon't be easy to remember where all the keys are though :) I do it the other way around, I sometimes have to write norwegian. But the number of characters I have to remember for that is less than what would be required for coding.
09:03alvin-xhm, jswat keeps hitting platform debugger related exceptions...
09:05rhickeyalvin-x: that keep it from working or just unwanted breakpoints? if the latter, you can probably filter them
09:06asbjxrnI tried setting a breakpoint, and I got exceptions, but jswat didn't react. Could it be because it happened in swings render thread?
09:08alvin-xrhickey: didn't set any BPs; just attached to a running REPL and tried to set the current thread by double-clicking the system/main/main thread... then JSwat hits unexpectede exceptions, and i'm not sure now what works and what doesn't...
09:10rhickeyalvin-x: It's been a while, but iirc, you can toggle exception breakpoints by type under breakpoints settings
09:10rhickeyit may be breaking on exceptions by default
09:15asbjxrnDuh, I was attaching jswat to the slime-swank socket...
09:21ChouserI may have to give up on trying to read all the overnight IRC traffic. It's certainly picking up.
10:14cemerickthe netbeans debugger will step through clojure code just fine, although there's a lot of "intermediate" stack frames that it forces you to step through unnecessarily
10:58AWizzArdMoin
11:01AWizzArdDoes it make sense to implement some (general purpose) data structures in Clojure? Like Skiplists or some kinds of trees? Maybe this is not needed, cause most data structures already have a very efficient implementation in Java and one could simply use those?!
11:26Chouseryou can certainly build trees out of vectors and/or maps.
11:26Lau_of_DKAfternoon gents
11:26AWizzArdWell, for real programming tasks you have to implement your datastructures for your code specifically. Your own tree, your own (map ..) and whatever.
11:27AWizzArdHi Lau
11:27ChouserAWizzArd: why? for performance?
11:27ChouserLau_of_DK: hi
11:27AWizzArdfor performance, usability, readability, and so on
11:27danlarkinAWizzArd: what "real" programming tasks would you have to do this for?
11:28achim_p_hmm, what do you use trees for, apart from representing higher-level data structures (which are very efficient in clojure). but if you're taking orders: an immutable doubly-linked list with O(1) cons from both ends, first/rest, last/butlast and reverse would be neat! :)
11:28AWizzArdFor pretty much every non-trivial hello world program you will need your own data structures
11:29danlarkinAWizzArd: I disagree
11:29AWizzArdof course in all cases they can be constructed by using already existing data structures
11:29Chouserachim_p_: and still Persistent, right? ;-)
11:29AWizzArddanlarkin: see even the most basic Clojure examples.. they often begin with a defstruct and then define some operations to work on that struct.
11:29danlarkinAWizzArd: a struct is just a hash with a static set of keys
11:30ChouserAWizzArd: so are you talking about general purpose data structures, or application-specific data structures?
11:31AWizzArddanlarkin: sure... but for your program it is a specific data structure and you don't think about it as a hash table. It is instead your data structure that manages employees or whatever.
11:31achim_p_i barely use stuff that's not representable via hashed/sorted sets, vectors or maps, really ...
11:31AWizzArdYou don't work with hashtable functions on it, but instead use an api for them
11:31achim_p_Chouser: of course! :)
11:32AWizzArdChouser: I was talking about general purpose data structures, like Skip Lists. But I see for example this: http://java.sun.com/javase/6/docs/api/java/util/concurrent/ConcurrentSkipListSet.html
11:33ChouserAWizzArd: clojure comes with several general purpose data structures that have some special concurrency features (immutable, persistent, transactionable, etc.)
11:33danlarkinAWizzArd: what does that buy you over #{}?
11:34Chouserfrom these you can build your application-specific data structures as in the examples you've sited. What else do you need?
11:35H4nsAWizzArd: if you need a skip list, write one or use what java provides. if you write one and if it has a neat api, it might be used by others. what else are you suggesting?
11:35AWizzArdH4ns: no suggestion, just asking for opinions
11:38H4nsAWizzArd: my opinion is: programming is fun. writing good libraries is great. sometimes i need advanced data structures and i'd rather reuse something that implement myself.
11:38AWizzArdH4ns: thanks, and I agree
11:39AWizzArdWhat I like to add is that it seems that Java now already has implementations for tons of advanced data structures. So probably most people really don't need to work on general purpose stuff like red black trees when we have maps which already are such kind of tree under the hood, with great improvements by Rich.
11:41Lau_of_DKachim_p_, the wiki is looking quite nice now huh? :) Some pretty good stuff in there
11:44achim_p_http://lamp.epfl.ch/papers/idealhashtrees.pdf
11:44achim_p_these are clojure's, if i'm not mistaken
11:46AWizzArdI think yes, and Rich said in one of his videos that those perform even better than the hashtables that come with Java. His words were something like: the fastest I have seen so far...
11:48achim_p_Lau_of_DK: good work! a nice repository of example code
11:48jdzis wanting a proxy of a proxy the wrong thing?
11:49jdzi mean, i want to create a proxy for a proxy, but i get exceptions...
11:49jdzone exception of method isInterface not being defined, to be precise
11:59Chouserdon't you need a class to make proxy of?
12:02jdzwell, a proxy (created using proxy macro) is a class...
12:02jdzor so the doc says
12:02ChouserI'm pretty sure it's an instance.
12:03ChouserI mean, calling proxy does create a class (if needed) but what it returns is an instance of that class.
12:04jdzyes, you are right.
12:07jdzChouser: do you maybe know if the functions provided to proxy macro are added to the class or to the instance? (sorry, my Java knoweledge is lacking)
12:08jdzanyway i think this discussion should be taken to mailing list for archiving purposes
12:10jdzshallow look at proxy source tells me the functions are added to the instance...
12:10Chousukemethods belong to a class in java though :/
12:10Chouserjdz: this channel is archived, though perhaps not as publicly as the mailing list
12:11Chousukeas far as I know you can't have two instances of a class with different methods in Java.
12:12Chousergoing from memory, I think proxy creates only one class per set of parent classes, with method stubs pointing to clojure fns
12:12jdzChouser: well, i have not yet looked at the Java side of the proxy implementation, but there sure is some magic going on.
12:12Chouserso calling proxy again with the same base classes but different method implementations reuses the existing class.
12:12jdzand update-proxy is called on the instance of created proxy class
12:12Chouserbut my memory or original understanding may be faulty.
12:13Chousukethat makes sense though.
12:13jdzChouser: your memory is consistent with what i see in the source.
12:13Chouserok
12:13ChousukeIt avoids creating unnecessary classes.
12:14jdzso proxy is not what i want, then.
12:14Chouserso maybe you could (let [i (proxy ...)] (proxy [(class i)] ...))
12:14jdztoo bad, i wanted an easy hack of xml parser...
12:14ChouserI've not tried that, though.
12:14jdzChouser: i tried, and that does not work. and it shouldnt't because i want the methods of the proxy instance
12:15jdzso looks like i'll have to look at gen-class...
12:15Chouserjdz: have you looked at clojure.xml/parse ?
12:16jdzChouser: that's the one i want to hack to enable me to provide my own implementation of resolveEntity method
12:17Chouseror clojure.contrib.lazy-xml/parse-trim
12:17Chouser(shameless plug)
12:17jdzChouser: well, i'd sure be glad to look at it. where do i get it?
12:18Chouserjdz: you can just start with a copy of that code and override an extra method?
12:18Chouserer, "can't you just"
12:18jdzChouser: that i did. but it does not solve the problem that the clojure.xml/parser is very limited...
12:18jdzwell, not very, but limited nevertheless.
12:19Chouserclojure-contrib is here http://sourceforge.net/projects/clojure-contrib
12:19jdzi hate the fact that calling setValidating on the parser factory does not disable validation
12:19Chousersvn get that and add clojure-contrib/src to your Java classpath.
12:20Chouserjdz: the SAX API is very unsatisfying.
12:20ChouserI hurts me every time I touch it.
12:20Chouser"It hurts me" sheesh.
12:24Chouserjdz: I always recommend using a pull parser over a SAX parser if it's at all an option: http://www.extreme.indiana.edu/xgws/xsoap/xpp/
12:29jdzChouser: ok, thanks. as i understand it, i have to download xpp for lazy-xml to work?
12:30Chouserjdz: no, there's some ugly code in there to provide the same API if all you have is the Java SAX parser.
12:31ChouserI mentioned it though mainly as another example of a proxy of org.xml.sax.helpers.DefaultHandler
12:34nicknullis there an easy to use webframework for cloure?
12:34nicknulla webserver
12:36Chousernicknull: compojure and webjure are two options
12:40nicknullwhich is the easier? i want something like webpy, just easy to do simple webapps, not a big kludge like django
12:41Chouserdunno, I haven't used either. ;-)
12:42Chousercompojure is newer, and may be trying to be more a lightweight set of libraries than an all-encompassing "framework", but I'm not terribly sure.
12:42ChousertWip: isn't webjure yours? care to comment?
12:45jdzone more question: how do i use a contrib after setting up the classpath?
12:45jdzsay, in the repl
12:46Chouser(require '[clojure.contrib.lazy-xml :as lx]) (lx/parse-trim ...)
12:46wlrChouser: tWip kinda did so in advance :-) check the recent overnight logs
12:46tWipsorry didn't follow, comment on what?
12:47Chouseror in a file, ns is preferred (ns my-namespace (require [cloure.contrib ...]))
12:47tWipaah, well webjure isn't really an all-encompassing framework either
12:48Chouserok, sorry. As I said, I haven't used either yet.
12:48nicknulla tried compojure, seems easy to grt going, just clone git and run script
12:48nicknullnice
12:48tWipit's a no frills approach to making clojure code easy to package and deploy as a servlet
12:49tWipI did include html generation, some jdbc code and so on, but it's mainly just a servlet that calls clojure
12:51tWipwhat I wanted was: (defh "/some/url*" [http param bindings...] ...code...)
12:51tWipwhere defh means define handler
12:51tWipthere is also (publish fn url-pattern)
12:51tWipbut that's all you really need to do
12:53PupenoHello.
13:10aperotteHello all, had a quick question about gen-class. If I want to use gen-and-load-class to subclass an abstract class, is the :methods mapping only for signatures or do you provide the code for the method as well. If not, where do you provide the code for the overridden methods? Lastly, I'm not sure I understand the :exposes mapping and the usage of the getter/setter methods. Does anyone have an example of gen-and-load-class u
13:13PupenoTo make a Compojure application, are you supposed to fork Compojure?
13:35Chouseraperotte: your post got cut off, but the basic idea is the gen-class creates a class with method stubs for all public methods of the classes it extends or implements.
13:36Chouserthe implementation of these should be provided as clojure functions in the appropriate namespace.
13:37aperotteoh ok, it only inherits the signatures, not the implementations
13:37Chouserso the only reason to use :methods is if you want to make up new methods not defined by any base class
13:38ChouserHere's a totally useless but functional example: http://paste.lisp.org/display/68406
13:39aperotteChouser: Thanks, I'll have a look
14:45ChouserIf stucture-basis objects implemented IFn, perhaps you could do: (defstruct point :x :y) (point 10 20) instead of (create-struct point 10 20)
14:46ChouserDoesn't that seem pleasant?
14:47wwmorganChouser: yes
14:47Chouseroh, sorry, instead of (struct point 10 20)
14:48danlarkin+1
14:50Lau_of_DKDoes anybody here have some Qt/Clojure code that they'd care to paste ?
14:51ChouserLau_of_DK: jamii posted this a while ago: http://paste.lisp.org/display/66213
14:52Lau_of_DKThanks Chouser !
15:02AWizzArdre
15:08Lau_of_DKYo
15:16cemerickChouser: re: struct-defs, that's very CL-y -- I'd be perfectly happy if defstruct emitted the basis obj, as well as point and accessors/"setters" for each slot (point-x, point-foo, etc)
15:17Chouserisn't (:x p) better than (point-x p) ?
15:18gnuvinceI think it is
15:18gnuvincePlus, it's less "magic"
15:20Chousergnuvince: what do you think of the struct-basis being callable?
15:21gnuvinceChouser: it makes sense.
15:21Chouseryou're already saying (defstruct point ...) so being able to call (point 1 2) wouldn't be too magic, right?
15:21gnuvinceI'm just looking hard to see if I can find problems with it.
15:21Chousergood!
15:21Chouserfind them before I'm tempted to start writing a patch.
15:34ChousukeI like that syntax. Trying hard to think of any downsides but unless that conflicts with clojure internals somehow I don't see any reason to reject that.
15:36Lau_of_DKHas anybody had some success running Clojurecode on .NET ?
15:37ChouserLau_of_DK: there were just instructions on that posted to the list.
15:37Lau_of_DKthe list?
15:37Lau_of_DKmailling list?
15:38Chouseryep
15:38Lau_of_DKNot the same as the Google Group ?
15:38Chousersame
15:38Chouserhttp://groups.google.com/group/clojure/browse_thread/thread/9e056bb3d2b078d2
15:39Lau_of_DKThanks Chouser
15:43cemerickChouser: I *really* like (:x p), but one of the key aspects of struct-maps is that you don't have to do a key lookup if you use an accessor fn
15:45Chouseroh yeah, the accessor functions. From the docs, those don't appear to give much performance benefit.
15:45rhickeycemerick: the perf difference is so slight
15:46cemerickrhickey: if you're using struct-maps heavily, then they're not so slight in my experience
15:47cemerickI've actually been fantasizing about what a PSM impl might look like given AOT, where the def'ed slots might become simple java fields, rather than members of an array.
15:48aperotteChouser: I tried using something similar to the example you showed me. It's entirely possible that I messed something up but it seems like gen-and-load-class can't ":exposes" a protected field that is itself inherited in the class I'm extending.
15:49cemerickI ended up refactoring a couple of classes away from using PSMs because the init costs are pretty high, compared to having an abstract base class that has the attributes you'd otherwise put in a def. Ensuring that def'ed slots become fields would resolve that.
15:54drewr"I may have to give up on trying to read all the overnight IRC |<vasa> soverton=> how can i make it?
15:54drewrWow, that pasted poorly.
15:54drewrAnyway, Chouser: :-)
15:55gnuvinceOh great
15:55gnuvincewe got drewc and drewr
15:55gnuvinceI am *so* gonna confuse the two of them
15:56altanim thinking about doing a little music prject in clojure, rhickey i heard you work on some really cool stuff, fingerprints, audion analsysis and stuff, you must have a really cool life. anyway what audio/analysis/composing program do you recommend?
15:58Lau_of_DKAnyone here using Vim/Clojure ?
15:58Chouseraperotte: that may be -- I think I saw something go by on the google group about how to get to protected fields further up the hierarchy.
15:58ChousukeI tried, but emacs offers much better repl integration :/
15:59aperotteChouser: Ok, I'll take a look, thanks!
16:03nicknullwhen i download java-libraries, where should i place them? in the JAVA-path or in clojure? should they be compiled before i can use them?
16:03PupenoI read here, http://www.reddit.com/r/programming/comments/77keg/webjure_simple_web_app_programming_for_clojure/c05w4xh , that compojure is much more active that webjure; would you say that's true?
16:03Chousernicknull: if you download a .jar, add that .jar to your Java classpatch
16:03nicknull.jar is ajava library?
16:04Pupenonicknull: yes, a Java ARchive, if I am not mistaken.
16:10drewrgnuvince: :-)
16:20drewcgnuvince: :)
16:21Chousukedrewc: you should've included the nose too.
16:21Chousershouldn't be hard to remember that drewr is the one with a nose.
16:21ChouserChousuke: ah, you beat me to it.
16:24drewrHaha. :)
16:24drewrSnap!
16:25AWizzArdChouser: I see that (coll? ...) is now in the api :-)
16:25drewcI was hoping you'd catch that .. lol thanks guys :-)
16:28AWizzArdWhy is (let [val (get {:a 1 :b 2} :a)] val) ==> 1 but (if-let [val (get {:a 1 :b 2} :c)] val 10 20) ==> Error, although 20 was what I expected?
16:28Chouserif-let doesn't take a vector
16:28ChouserI think this will be changing before the 1.0 release of clojure
16:29AWizzArdah okay, the binding vector, I see
16:29Chouserfor now, (if-let val (get...) val 10 20)
16:29Chousersorry, (if-let val (get...) 10 20)
16:30AWizzArdbut where is the test?
16:30nicknullif im looping and (if (not= cond)... is true i need to do 2 things, print and then recur
16:30AWizzArdwhere is the test form?
16:30nicknullusing when i get complaint must recur from tailposition
16:30ChouserAWizzArd: the value assigned to val will be the test
16:30AWizzArdgood
16:31nicknulland using if i can only use one stataemnt
16:31Chousernicknull: you can say (do (print ...) (recur ...)) but I expect you'll get the same error as with "when'
16:31Chousernicknull: paste your code?
16:33lisppaste8nicknull pasted "recur" at http://paste.lisp.org/display/69020
16:35drewrnicknull: Try if.
16:36lisppaste8Chouser annotated #69020 with "recur in tail position" at http://paste.lisp.org/display/69020#1
16:37Chousernicknull: the problem was the (pr "Not found") you had later.
16:38ChouserAlso it's better not to use (not= x nil) unless you really need it. That's the same as just x unless x is sometimes false.
16:39nicknulli see thanks
17:55Lau_of_DKuser=> (map int->seq [12345 54321])
17:55Lau_of_DK(#{1 2 3 4 5} #{1 2 3 4 5})
17:55Lau_of_DKuser=> (apply == (map int->seq [12345 54321]))
17:55Lau_of_DKfalse
17:55Lau_of_DKIts 4 minz to midnight here, help a tired brain make this eval to true :)
17:57nicknullcompojure is very good!
17:57wwmorganLau_of_DK: why are you using ==?
17:58Lau_of_DKargh
17:58Lau_of_DK:)
17:58Lau_of_DKwhats the difference?
17:59wwmorganthe docs make me believe that == is for numeric equality
18:00Lau_of_DKk
18:00Lau_of_DKthanks for pointing that out, works now, bed time
18:00AWizzArdLau_of_DK: (== true true) ==> false
18:16AWizzArdWhat is the right way to provide patches for Clojure? Uploading a diff to the google group? Sending Rich an email?
18:37nicknullwhy do people use other webservers than apache?
18:37nicknulli mean what strengths weaknessses does it have?
18:38wwmorgannicknull: I think compojure requires jetty
18:46AWizzArdwwmorgan: thanks for your reply about Currying. I just think that partial is not nice enough. In principle it could go away if we had full currying.
18:46wwmorgancan you explain the rgb use case? I don't get it
18:48AWizzArdrgb is a hypothetical function that returns a color object. Currying is syntactic sugar. It provides nothing that couldn't be done by using fn. Macros are all about syntactical sugar. So in my example I want:
18:48AWizzArd#(rgb _ 0 255) ==> this creates a new function on-the-fly. This new function takes one argument.
18:48danlarkinAWizzArd: isn't partial basically doing currying? Or am I misunderstanding what currying is
18:49AWizzArddanlarkin: yes, it is currying and you understand it correctly. I want currying that goes even further. Have a look at the google groups.
18:49wwmorganright now that case is covered by #(rgb % 0 255) right?
18:49AWizzArdYes, this case is covered.
18:49AWizzArd#(rgb _ _ 255) is't
18:49AWizzArdisn't
18:50AWizzArdyou need to be a bit more talkative by explicitly listing the argument number
18:51AWizzArdwhat I suggest is adding a throw-away underscore _ for arguments about which you don't care. You list only args that you care about. And this happens only if you need to repeat them.
18:51AWizzArdFor example for making a squaring function: #(* %1 %1). I want to keep that.
18:52ChouserAWizzArd: Rich only accepts patches if he's received your CA and you submit your patch via google group (attached to a message or uploaded to the files.)
18:52AWizzArdBtw, what is a CA?
18:52ChouserAWizzArd: it seems to work best to send a description to the group with a diff attached.
18:53ChouserAWizzArd: http://clojure.org/contributing
18:53Chouserhm, I should have just posted that first.
18:54AWizzArdthx
19:28jaowhat's the idiomatic way of defining/signalling errors? do i need to use java exceptions?
19:37Chouserjao: that's a fine option, or some people are experimenting with calling a fn in a dynamically bound var to signal an error.
19:38jaoChouser, aha... i'm not sure i understand the alternative to exceptions: could you give me an example, please?
19:39Chouserlet me see if I can find the discussion thread.
19:45nicknull(import '(javax.imageio.ImageIO)) <- correct right? , how do i then use that?
19:45nicknull static ImageInputStream createImageInputStream(Object input)
19:45Chousernicknull: no. (import '(javax.imageio ImageIO))
19:46Chousernote the space instead of the dot
19:46Chouser(ImageIO/createImageInputStream input)
19:47nicknullshould it work in the repl? it just retusn nil. an it does so if i import rubbish too
19:48Chouserimport returns nil
19:49Chouserjao: here is some high-level discussion: http://groups.google.com/group/clojure/browse_thread/thread/90eae0f570989254/951b5f04d53ebca3
19:49jaothanks!
19:49Chouserjao: and here is some code (possibly not correct): http://groups.google.com/group/clojure/browse_thread/thread/3beb90914b4b5e70/8f4186fc21b73bc2
19:50jaoexcellent
19:53larrytheliquidis there an example of this somewhere? "It is possible to create vars that are not interned. These vars will not be found during free symbol resolution, and their values have to be accessed manually. But they can serve as useful thread-local mutable cells."
19:53Chouserlarrytheliquid: that may be referring to var-local-vars
19:55larrytheliquidChouser: that makes sense, thanks
19:55Chouserlarrytheliquid: where's the quote from?
19:55larrytheliquidhttp://clojure.org/vars
19:55larrytheliquidunder find-var
19:58lisppaste8Chouser pasted "with-local-vars example" at http://paste.lisp.org/display/69031
19:59nicknullChouser: if import or uses of JAVA-libraries fail, arent exceptions raised?
20:00nicknulllike im using a method that should return a java-object and i just get nil
20:00Chouseruser=> (import '(foo.bar bang))
20:00Chouserjava.lang.ClassNotFoundException: foo.bar.bang (NO_SOURCE_FILE:0)
20:00nicknulli dont know id that means failure to open file, find file, to fidn javamethod
20:04Chouserif your import returns nil, it succeeded.
20:20jaohmm. is there a type predicate for procedures?
20:24nicknullnew BufferedReader(new FileReader("xanadu.txt"));
20:24nicknullhow do i pass that?
20:30danlarkin(BufferedReader. (FileReader. "xanadu.txt"))
20:32danlarkinalternatively: (new BufferedReader (new FileReader "xanadu.txt))
20:33nicknulland i can use them without any prefix?
20:33nicknulllike java/BufferedReader?
20:33danlarkinfirst you have to import them
20:33danlarkin(import '(java.io BufferedReader FileReader))
20:36nicknullthe . at the end is the same as new before?
20:37danlarkinya, it's reader syntax
20:44nicknullhttp://hpaste.org/11406
20:44nicknullcan someone help me here, i get nil back when i should get some sort of strema from JAVA
20:45nicknullman JAVA really seems to complicate evrything to the maximum
20:46waltersnicknull: you shouldn't use *Reader for binary data
20:47waltersnicknull: just create a FileInputStream
20:47waltersnicknull: the imageio docs also say you can just pass it a File
20:47walters*Reader is for Unicode text
20:48walters(why the imageio API has some sort of magic dispatch-on-Object instead of proper overloads, I have no idea)
20:49nicknullhow do i create an imageinputstream? im not familiar wth Java very much. or a file? open(path)?
20:50AWizzArdDoes anyone of you know the Ants example that Rich showed in his concurrency vid?
20:51abrooksAWizzArd: What about it? Are you looking for the sources?
20:51AWizzArdI have them
20:51AWizzArdI have a question about it
20:51waltersnicknull: looks like this works: (ImageIO/createImageInputStream (new File "/usr/share/icons/abiword_48.png"))
20:52AWizzArdIn the video I think he said that change the behaviour of the ants, as he wishes, at runtime. Is that right?
20:55nicknullthanks walters appreciate it
21:45ChouserAWizzArd: yep, I think he says that in the video
21:48AWizzArdI think I will have to study that code
21:50cemerickdoes anyone recall any detailed discussion of the AOT impl so far on the channel? I'm trying to understand what's going on with #=, but that's pretty hard to search for :-)
21:51ChouserAWizzArd: I believe he was refering to re-def'ing behave at the repl while the demo's running.
21:52Chousercemerick: that's just a new print format for previously unreadable objects
21:56cemerickok, that helps.
21:57ChouserI do have a link here -- hang on
21:58Chouserhttp://clojure-log.n01se.net/date/2008-10-11.html#11:06d-11:48
22:00cemerickChouser: great, thanks
22:00cemerickgotta get those pre-AOT macros workin
22:00Chouserhm?
22:07AWizzArdOh nice, the Clojure reader has no side effects, it does not intern symbols, as it does in CL. So this means I can use it as an improved load-xml :-)
22:09Chouseryou can't use the CL reader to load plain data?
22:14AWizzArdWhat tests?
22:15AWizzArdChouser: CLs reader "interns" symbols. It causes side effects.
22:22ChouserI knew rhickey has made a point of how Clojure's reader is free of side-effects, but I didn't realize this mean CL's reader couldn't be used for just reading data.
22:26arohner`(let [[a b] {:a 1}]
22:27bkearnsI wos wondering a little about the output of printing an object.
22:27bkearnsafter reading http://clojure-log.n01se.net/date/2008-10-11.html#11:06d-11:48
22:28bkearnsI thought something like
22:28bkearns#=(Object. "ctor args") ;; 0xADD ; Sess Timestamp
22:29bkearnscould potentially be used to point to an existing object in memory
22:29bkearnsand then you could run your entire repl session back if the user-> prompt were ;user-> and all expeptions were preceeded by ;'s as well.
22:31AWizzArdDo we have access to the byte code that is generated by the compiler?
22:32Chouserinteresting idea. Currently the older values have probably been garbage collected -- you'd have change the repl to hang onto all those values
22:33bkearnsI wonder if there's a callback on the GC thread to tell you what the address of the objecst being collected are
22:33Chouserthe repl currently keeps the last 3 values I think. You could extend that to keep all of them I suppose.
22:34ChouserAWizzArd: not easily. why?
22:35AWizzArd(= #(+ 4 %) #(+ 4 %)) ==> true
22:35Chouserwow.
22:35arohner`is there any reason why set! could not be extended to work on vars created by with-local-vars?
22:35AWizzArdyou say wow Couser, but in reality the result is false.
22:37bkearnsIt should be false, each of the #() forms gets compiled to a separate class thus generating different objects I think.
22:37AWizzArdThen why should (= "hallo" "hallo") ==> true?
22:37AWizzArdThose are two separate strings, in two different memory locations
22:37bkearnsbecause in the JVM strings are interned
22:38bkearnsso they point to the same memory location
22:38Chouserno, = is a value comparison, not like identical?
22:38danlarkinno, = operates on value
22:38Chouserwhat he said. :-)
22:38AWizzArdthen let's do: (identical? [1] [1]) ==> false
22:38bkearns(= (File. "/tmp/foo") (File. "/tmp/foo"))
22:39bkearns==> true
22:39waltersbkearns: not always, I don't believe
22:39waltersmaybe Clojure's reader calls .intern() on strings
22:39bkearnsI think all strings do that's why they're immutable in the JVM.
22:40AWizzArdforget strings
22:40AWizzArdtake vectors then instead
22:40ChouserClojure interns strings currently, but I don't think that's guaranteed.
22:40waltersbkearns: they were originally immutable for security reasons
22:40AWizzArdWhen [1] and [1] are two different objects and (= [1] [1]) yields true, then why shouldn't (= fun1 fun2) yield true if they compiled to the same byte code?
22:41bkearnsright and then there would be no need for the inter() on the String object...
22:41waltersAWizzArd: they could be capturing different environments
22:41danlarkinAWizzArd: you don't know they're the same bytecode though :-D
22:41danlarkinwhat walters said
22:41bkearnsI was last dealt with low level messing with Jython and Terracotta and Jython interns strings.
22:41AWizzArddanlarkin: that's why I asked if there is a way to get the byte code of an object
22:42AWizzArd(= (byte-code fun1) (byte-code fun2))
22:42danlarkinTBH I don't know how = is defined on functions
22:43AWizzArdI think = on functions is like CLs eq
22:43Chouser#(+ 4 %) doesn't return bytecode anyway, it returns an instance of Class
22:43AWizzArdso it looks if they have the same address in memory
22:43danlarkinAWizzArd: no, = is different from identical?
22:43AWizzArdChouser: and can't class instances be represented by byte code
22:43danlarkin= is always a value compare, identical? is a pointer compare
22:43AWizzArddanlarkin: sure, for most things, but for functions they seem to be the same
22:44ChouserI'm not completely sure, but it may be that the Class class doesn't have an equals() method, and thus Clojure's = returns false.
22:45AWizzArddanlarkin: can you otherwise provide one example of where (= fun1 fun2) ==> true and at the same time (identical? fun1 fun2) ==> false, or vice versa?
22:46danlarkinno, doesn't mean it isn't the case though
22:46waltersAWizzArd: i don't think you can get the bytecode easily; you might be able to look at the classloader of the class of the method and find the on-disk source if the class came from disk
22:47waltersbut if it was generated at runtime or pulled from the network i'm not sure the JVM is guaranteed to keep it around
22:47bkearnsdoesnt' the JVM make sure the classes of the objects are the same before calling equals()
22:47waltersbkearns: no
22:47AWizzArdokay, so for non-trivial cases we can't compare functions with each other
22:48AWizzArdI understand that this is for technical reasons, and in practice one does not compare functions with each other often, but this is an irregularity
22:49ChouserHm, all objects provide .equals -- anyway, it appears to be Java that's returning that false.
22:50Chouserrhickey has warned about equality semantics of Java objects.
22:58msingh24~
22:58msinghoops. sorry!
22:58arbschtheh, hi msingh
22:59arbschtchannel's growing fast
23:08AWizzArdif I don't want to use rationals, is there a way to get abritery precision for floats?
23:09ChouserBigDecimal
23:09AWizzArdcan you give me an example call on how to add two of them?
23:10Chouser(+ 12.34M 56.78M)
23:11Chouserclojure.lang.Numbers is crazy.
23:12AWizzArdAnd can I enforce the representation to be human readable? If I type 0.0000001M I will see the printer giving me that one back
23:12ChouserHm, doesn't look like it.
23:12AWizzArdok, I see this only happens to these mana zeros in a row
23:13AWizzArd0.123456789M shows me the right thing
23:13Chousereven 1.000000000001M
23:13AWizzArdok, good then
23:19AWizzArdDo you have a minimal example which shows that let and binding behave different?
23:20AWizzArdin the context of concurrency I mean
23:21AWizzArdof course binding can only bind symbols that were already introduced in the context
23:24AWizzArd(binding [unknown 10] unknown) ==> error but (let [unknown 10] unknown) ==> 10... but I am talking about http://clojure.org/vars#toc1 and in this example it behaves like let.
23:28Chouser(binding [x 2] (send-off (agent nil) (fn [_] (Thread/sleep 100) (prn :x x))))
23:28arohner`AWizzArd: you can use set! on vars inside of a (binding [])
23:29arohner`binding can also change the value of a def
23:29AWizzArdcan't let change the value of a def lexically?
23:29arohner`(def x 5) ( binding [x 7] (println x) (set! x 9) (println x))
23:29arohner`that's a different object
23:30arohner`using let, you create a different object with the same name
23:30AWizzArdso, inside a (binding ...) I can use (set! ..)
23:30arohner`yes
23:30AWizzArdWhat is this good for? :-)
23:30ChouserAWizzArd: yes, and that "change" will be "global" for that thread.
23:31ChouserAWizzArd: CL allows for dynamically bound variables, right?
23:31AWizzArdyes
23:31Chouserthat's what binding does.
23:32arohner`the effects of set! last until the end of the binding scope, right?
23:32arohner`and leaving the binding resets things?
23:32Chouseryep
23:32AWizzArdI still don't get what it is good for. Making a thread wide change of that varaible should not have any effects, as nothing runs parallel in a thread.
23:33Chouserbut again, that's all just for the one thread. Other threads can have their own bindings and be doing their own set!s on the same var
23:33arohner`AWizzArd: you can use it 'signal' behavior in other places in the stack
23:33ChouserAWizzArd: it can be used to "pass" data down the call stack without it having to be in every parameter list
23:34ChouserAWizzArd: with set! it can be used to "return" extra results back up the stack
23:34AWizzArdCan you show a small example for this?
23:34danlarkina set of functions that make modifications to a list, you don't have to pas the list to every function
23:34Chouserthere was a macro on the google group recently that implemented a sort of multiple-value-bind using binding
23:35Chouserhttp://paste.lisp.org/display/68919
23:48AWizzArdokay, now I got it
23:50AWizzArdit seems that binding is doing more or less what CLs let is doing
23:51lisppaste8AWizzArd pasted "What is (binding ..) good for?" at http://paste.lisp.org/display/69040
23:52sohailhow the heck do you read in a list of integers without creating N lists?
23:52AWizzArdWhat do you mean by 'read'?
23:52sohailfrom the user
23:52sohailI guess I should use recursion there
23:53AWizzArdDo you mean you use the Clojure reader? As in (read) ?
23:54sohailyeah