#clojure logs

2008-12-12

04:14AWizzArdMoin moin
04:17Lau_of_DKHola Senior
04:25AWizzArdque tal?
04:57Brackiclojure.lang.PersistentHashMap cannot be cast to java.util.Map
04:57BrackiSo how do I get a Map from {}?
05:08ChousukeBracki: are you running the release version of clojure?
05:09ChousukeBracki: you'll have to use a more recent version
05:11Brackiyeah running svn this very moment
07:12Kerris7http://blog.rubyenrails.nl/articles/2008/12/12/calling-clojure-from-jruby
07:12Kerris7Clojure + jRuby :o
07:40Lau_of_DKKerris7: Calling Clojure FROM Ruby? Thats gotta give some overhead
07:40Kerris7jRuby
07:41Lau_of_DKSame
07:42Chousukewell, jruby already runs on the jvm so the overhead should be minimal
07:47Lau_of_DKI doubt it
07:47Lau_of_DKRuby is grade F material
07:48Lau_of_DKhttp://shootout.alioth.debian.org/gp4/benchmark.php?test=all&lang=all
07:51blackdogwell to give ruby it's due it at least showed "enterprise" developers that they'd been duped by complexity for too long
07:55blackdogas does clojure
07:58ChousukeLau_of_DK: I thought you meant the overhead of combining ruby and clojure :)
07:59Chousukeif they'd just get 2.0 out the rubyists might actually save themselves
07:59Chousuke1.8 is just meh.
08:00Lau_of_DKI might be wrong, but to me it looks like all Ruby is released under the slogan "For noobs, by noobs", like Python
08:07rhickeyShould be an interesting day in the blogosphere: http://tapestryjava.blogspot.com/2008/12/clojure-hundred-year-language.html
08:09leafwrhickey: clojure is becomming what arc was designed for. But I don't think PG cares at all.
08:12rhickeyI don't think so either. It's quite flattering, but I'm always concerned about not overstating things for Clojure
08:13ChouserI think that attitude, as well as standing well clear of general language bashing, have been wise and served Clojure well.
08:14leafwas the saying goes: be so good that, even when hated, nobody can afford to ignore you.
08:16blackdogi think you're well covered rhickey , as for example ruby backlash is on scalability, you i can't imagine a lot of complaints on the language itself
08:16blackdogclojure that is
08:19octewhat does "#" mean in clojure? i'm looking at the built-in and-macro..
08:20rhickeyocte: # is a dispatching reader macro, whose meaning is determined by the next character, documented here: http://clojure.org/reader
08:22octethanks, i was looking for a reference for the macro characters :)
08:26thoughtpoliceapparently android's dx tool does not like the clojure.jar file :(
08:29thoughtpoliceand i finally got the AOT compiler to work and compile my stuff against android.jar, at least.
08:30rhickeythoughtpolice: I only got to try it for a few minutes (dex), and saw one bytecode thing its verify didn't like (but Java's does, as Clojure bytecode does verify). Have you got a specific problem?
08:31AWizzArd# can also be a postfix reader macro, as shortcut for gensym.
08:37AWizzArdrhickey: yesterday we discussed static typing for some moments. In that regard, do you think that it could make sense one day to have no automatic (empty) implementation for checked exceptions?
08:38rhickeyAWizzArd: I don't understand
08:39AWizzArdAs I understand it, in Java there are so called checked exceptions. You are not forced to put a division every time you want to use it into a try/catch block. But with checkey exceptions you have to.
08:39AWizzArdchecked
08:40AWizzArdIn Clojure you never have to put anything into a try/catch block I think.
08:40AWizzArdEven when you do something that would require such a try/catch block in Java.
08:41AWizzArdOr is my understand not correct?
08:41rhickeyyou want checked exceptions for Clojure?
08:42gnuvinceGod no!
08:42AWizzArdI don't know, but I would like to hear your opinion (as you have much more Java experience than I have). Could that make sense? Would that help programmers?
08:42rhickeyChecked exceptions are a horrible misfeature of Java
08:43AWizzArdoh, I see
08:45gnuvinceAWizzArd: it makes no sense to force people to handle exceptions if they don't know how they should handle them; you just end up rethrowing them.
08:46AWizzArdHmm I see. At a first glance it sounded as if this could improve the program safety. The programmer would have to think about her program would continue in an exceptional situation.
08:46Chousukeyou just end up adding the same boilerplate code every time :(
08:46AWizzArd+how
08:46AWizzArdI see, didn't know that.
08:47ChousukeI'm glad I have strong hair, otherwise I might already be bald from all the hair-ripping I've done when dealing with java exception handling. :)
08:47thoughtpolicerhickey: seems to be something like that - http://paste.lisp.org/display/72026
08:47AWizzArdThe intentions of Sun were good, but practice showed they were wrong.
08:50thoughtpolicerhickey: but no real specific question; I was trying to learn clojure so I decided to look around for some java related stuff I could harness from it; might go back to hadoop or something since android no workee :(
08:55rhickeythoughtpolice: android is an eventual target, but anything involving bytecode transformation might need work, since many of these tools are looking for the output of javac
08:56rhickeythoughtpolice: ok - that's the same thing I saw, will look into it when I get time
08:56Chouserwouldn't the dynamic loader that gives applets fits similarly be a problem for android?
09:30jdzI think assert macro should accept a message argument so that a message with runtime values (instead of test form) could be generated. something along the lines of this: http://paste.lisp.org/display/72027
09:31jdzcould be used like: (let [n 42] (assert (odd? n) "number should be odd: " n))
09:33jdzthe addition is too small i don't want to bother the mailing list...
09:33jdzsomebody with commit rights could commit it; or tell me to bugger off :)
09:33jdz(in which case i'd go to mailing list, anyway :)
09:34Chouseronly rhickey has commit rights
09:34jdzfair enough
09:34jdzthen i send him an email if i don't get flamed too much
09:35jdzand if he does not see it here
09:40RSchulzjdz: You can do this: (let [n 42] (if-not (odd? n) (throw (new Exception (str "number should be odd: " n)))))
09:40RSchulzNot as concise, of course.
09:40RSchulzOr you could just write your own "assert2" or some such.
09:41jdzand i can have my own extended version of assert, too.
09:41jdzbut there is a good reason why i think it should be in the clojure.
09:41jdzand it's backward compatible.
09:42jdzthe only question is about the message formatting.
09:42RSchulzLike Chouser said, propose it. Rich won't flame you.
09:42RSchulzBut not here, naturally. On the list.
09:43jdzyes, looks like the list is the right place to go after all.
09:44jdzno change is small enough not to deserve an extended discussion :)
09:52hiredmanclojurebot: rhickey?
09:52clojurebotIt's greek to me.
09:53hiredmanclojurebot: rhickey is a T-1000 sent from the future
09:53clojurebotc'est bon!
09:57RSchulzhiredman: You need to teach clojurebot some critical thinking skills...
09:58hiredman?
09:58RSchulzclojurebot: hiredman is a three-toed sloth
09:58clojurebotRoger.
09:58RSchulzIt's a bit gullible, no?
09:59hiredmandamn it, you just overwrote the two previous entries for hiredman
09:59RSchulzWhat were they?
09:59drewrclojurebot doesn't version?
09:59AWizzArdWe'll never find out...
09:59hiredmanclojurebot: hiredman is also slightly retarded
09:59clojurebotc'est bon!
10:00RSchulzThat's an idea. You could give it a syntax (maybe a leading +) that causes it to add to an existing entry.
10:00hiredmanif you use also, it adds multiple entries to something, and then randomly picks one
10:01hiredmanclojurebot: hiredman?
10:01clojurebothiredman is slightly retarded
10:01RSchulzIf "also" appears anywhere in the statement?
10:01hiredmanif also appears after is
10:01hiredmanis also
10:01RSchulzAh. But your "is also" displaced the previous record.
10:02hiredmando
10:02hiredmanno
10:02hiredmanis also turn the record into a vector containing multiple records
10:02hiredmanturned
10:02hiredmanat lookup one record is randomly chosen from the vector
10:02danlarkinclojurebot: hiredman?
10:02clojurebothiredman is slightly retarded
10:03danlarkinclojurebot: hiredman?
10:03clojurebothiredman is slightly retarded
10:03danlarkin:o
10:03RSchulzclojurebot: braindump
10:03clojurebotTitim gan �ir� ort.
10:03RSchulzclojurebot: braindump?
10:03clojurebotIt's greek to me.
10:03hiredmanspaces
10:03RSchulzclojurebot: brain dump?
10:03clojurebotbrain dump is http://clj.thelastcitadel.com/clojurebot
10:03RSchulzService Temporarily Unavailable
10:03hiredmanoh
10:03RSchulzThe server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.
10:04RSchulzDamn computers. Can't live with 'em, can't live without 'em.
10:04hiredmanshould be good now
10:04RSchulzStill STU
10:04hiredmanserver lost power last night
10:04RSchulzThere we go.
10:05hiredmanhmmm
10:05RSchulzSo the brain dump shows the keys but not the associated answers?
10:05hiredmanclick on the keys
10:05hiredmanit still shows the old entries
10:05RSchulzSlick.
10:05RSchulzIt looks like plain text, but it's actually super-fancy AJAX...
10:06RSchulzThe entry you added for rhickey doesn't seem to be there
10:07hiredmanrefresh
10:07RSchulzWeird. It's there now.
10:08hiredmancompojure is running in a different jvm then clojurebot, so it slurps up the clojurebot.is file, that clojurebot writes every, I dunno, maybe ten minutes, or whenever I manually run (dumpdicts) like I just did
10:09RSchulz"It's always something."
10:09rfgpfeifferis there a powerset function for sets?
10:10cemerickrhickey: this is an interesting development: http://www.bitbucket.org/stefanrusek/xronos/wiki/Home
10:11RSchulzrfgpfeiffer: I don't think so. In Clojure Contrib there are some simple set utilities, but I don't see a powerset there.
10:11RSchulzrfgpfeiffer: Is there a canonical FP algorithm for computing powersets?
10:12gnuvinceYou can use the binary trick
10:12gnuvincethat works best with collections with O(1) access time
10:12rfgpfeifferRSchulz: when the set implements seq, then yes
10:13rhickeycemerick: I've seen that - no copyright/license etc, still considering a response
10:13RSchulzgnuvince: What's "the binary trick?"
10:13Chouserrhickey: it claims BSD license
10:13RSchulzcemerick: I know what CLR is. What's DLR?
10:14cemerickRSchulz: Dynamic Runtime Library, I believe
10:14rhickeyChouser: but is it free of Clojure-copyrighted material?
10:14RSchulzWhich itself runs on the CLR?
10:14cemerickyeah
10:14blackdogit's what ironpython is based on - an extension to clr
10:14cemerickan established way for dynamic languages to hook into the platform, APIs, etc
10:14ChousukeRSchulz: dynamic language runtime
10:14ChousukeI think :P
10:14cemerickugh, yes, runtime.
10:15cemerickStill tired, I guess -- mixing up my R's and L's :-P
10:15gnuvinceRSchulz: http://en.wikipedia.org/wiki/Powerset#Representing_subsets_as_functions
10:15RSchulzgnuvince: Thanks.
10:16gnuvinceRSchulz: I have a small implementation
10:16gnuvinceI'll paste it
10:16cemerickrhickey: I actually didn't notice the licensing on the Xronos bit -- it's an acceptable usage of clojure, assuming he dots the i's with the license and copyright, yes?
10:16RSchulzGreat.
10:17rhickeycemerick: he can't relicense Clojure as BSD nor leave off copyright notices
10:17RSchulzI have Java code for the four basic set algorithms.
10:17RSchulz...operations...
10:17gnuvinceHmmm
10:17cemerickrhickey: sure, that's definitely a no-no
10:17gnuvinceis paste.lisp having problems?
10:17blackdogis it still clojure though? i suppose that'll be the argument
10:17rhickeycemerick: that's what it looks like right now
10:17Chouserrhickey: spot check on his PHM, looks hand-written and perhaps not even directly translated from Clojure
10:17danlarkinblackdog: it only has to be based on clojure
10:17danlarkinblackdog: to be a derivative work
10:18blackdogok
10:18drewolsonhey all, i'm trying to write a lazy prime seive and i thought this was it: http://gist.github.com/35146
10:18drewolsonbut i get a heap exception if i do (nth (primes) 10000)
10:18gnuvinceRSchulz: http://pastebin.ca/1283606
10:18drewolsonwhere do i lose the laziness?
10:18RSchulzThanks.
10:18RSchulzHow many of these "paste" sites are there??
10:19cemerickI'm guessing he's just not aware of the issues around the license and copyright notices, etc. Otherwise, he wouldn't have even specified that it was a derivative of clojure.
10:19Chouserrhickey: for example his PHM.seq() appears to copy the entire think into a List.
10:19Chouserthing
10:19RSchulzgnuvince: Wouldn't it be possible to collaps those two (for ...) forms into one?
10:20gnuvinceRSchulz: probably; I was still a wet-behind-the-ears Clojurist when I wrote that.
10:20RSchulzAnyway, that's cute. Thanks again.
10:20Chouserdrewolson: http://www.cs.hmc.edu/~oneill/papers/Sieve-JFP.pdf
10:21RSchulz'Cept where are the individual sets comprising the powerset created?
10:21drewolsonChouser: thanks...is the gist of the paper that i haven't actually implemented the "true" algorithm?
10:22Chouserdrewolson: it's that what you're implementing is much slower than a sieve.
10:22drewolsoni see
10:22Chouserdrewolson: just like mine and everyone else's lazy prime sequence.
10:22RSchulzWell, it works. I'll have to figure out how. (Don't tell me!)
10:22drewolson:)
10:22drewolsonbut i still don't understand how it's not lazy
10:23drewolsoni guess that's my main question
10:23Chouserthe paper has an algorithm (in haskell :-P) for a fast lazy prime seq.
10:23drewolsonoh man, haskell is very foreign to me
10:23drewolsoni'll give it a shot
10:24gnuvincedrewolson: get Real World Haskell
10:24mfredricksondrewolson: i have a version in scheme if you want it
10:24Chouseryeah, I meant to try, but the haskell is pretty impenetrable for me.
10:24gnuvincedrewolson: http://book.realworldhaskell.org/read
10:25drewolsoni'm actually less interested in the "true" implementation than why this implementation is not lazy
10:25drewolsonwhere did i lose laziness?
10:25RSchulzgnuvince: One last thing: It would probably be better if the empty subset that's part of every powerset were '(), not nil, wouldn't it?
10:25AWizzArdChouser: F# is maybe the easier step after Clojure, and only then Haskell.
10:25ChousukeRSchulz: do you mean #{}? :)
10:25drewolsongnuvince: thanks, i'll check that out
10:25RSchulzWell it doesn't return sets, it returns lists.
10:26RSchulzuser=> (powerset ['a 'b 'c])
10:26RSchulz(nil (a) (b) (a b) (c) (a c) (b c) (a b c))
10:26Chousukehm
10:26Chouserdrewolson: as to why yours is blowing the heap, cgrand just taught me this a couple days ago. I'll find the link...
10:26Chousukeare you sure those are lists and not just sequences?
10:26drewolsonChouser: great, thanks :)
10:26RSchulzuser=> (map class (powerset ['a 'b 'c]))
10:26RSchulz(nil clojure.lang.LazyCons clojure.lang.LazyCons clojure.lang.LazyCons clojure.lang.LazyCons clojure.lang.LazyCons clojure.lang.LazyCons clojure.lang.LazyCons)
10:27gnuvinceRSchulz: they're lazy cons
10:27gnuvinceI guess you just saw that )
10:27gnuvince:)
10:28Chousukethey should be sets, but that would destroy the laziness I guess :/
10:28Chouserdrewolson: http://groups.google.com/group/clojure/msg/5a543d1a75c5fa28 -- but reading it again, it's a little harder to understand than I remember. feel free to ask more questions. :-)
10:28RSchulzThe "binary trick" (as implemented, anyway) relies on them being indexable collections.
10:28drewolsonChouser: i'm sure i will
10:28kyleburtoncould someone assist me with trying the compile example from: http://clojure.org/compilation?
10:29kyleburtonwhen I attempt to call (compile 'app.hello) I get: java.io.IOException: No such file or directory (hello.clj:2)
10:29kyleburtonthough a (require 'app.hello) succeeds (results in nil)
10:30kyleburtonwhich I think implies that the classpath is right
10:30gnuvinceRSchulz: yes.
10:31gnuvinceRSchulz: there is another recursive way to do it, but I never got my head around it.
10:31jdzkyleburton: not really. make sure the [created] 'classes' folder is in classpath, too.
10:31kyleburtonjdz: will try, thank you
10:31drewolsonChouser: wow, that is confusing...sees counter-intuative that storing the result in a let would keep the laziness
10:32jdzkyleburton: make sure it is in classpath and *exists* before compiling.
10:32jdzbefore launching clojure that is
10:32RSchulzIf I was doing it in Java, I'd probably dump an arbitrary set into an array do the binary trick from there. I'd probably also generate the resulting (sub-)sets on an as-needed basis in the contains(...) and iterator methods. Assuming that would work for the full complement of the Set interface.
10:32Chousukerhickey: about that Xronos thing... the clojure licence is compatible with BSD, isn't it? So providing they add the CPL copyright/licence notices, they could still mix the BSD-licenced code with clojure's CPL code, right?
10:33kyleburtonjdz: that got me to another error: java.lang.RuntimeException: java.lang.ClassNotFoundException: app.hello$_main__1316 (NO_SOURCE_FILE:0)
10:33jdzkyleburton: read what i wrote after.
10:33kyleburtonjdz: it exists, tho I my have neglected to add-classpath...thanks
10:34jdzi think Clojure should warn if the classes folder is not in classpath...
10:34kyleburtonjdz: thank you, it compiled
10:34rfgpfeifferpowerset for seqs: http://gist.github.com/35157
10:35rhickeyChousuke: anything derived from Clojure must be CPL, it can be combined with anything (except GPL, but that's GPL's choice)
10:35ChouserChousuke: that may be, but the page implies that all of Xronos is BSD, which can only be true if there's nothing clojure-derived in it.
10:36AWizzArdaha, that's how it works
10:36RSchulzrfgpfeiffer: I didn't realize let's destructuring allowed optional elements via &! That's very cool.
10:37ChousukeChouser: I suppose that need to be investigated.
10:37ChouserRSchulz: the one thing named after & is bound to a seq
10:37AWizzArdI think you can binding and destructuring is everywhere the same, in defn, fn, let, binding, with the exception of def
10:37danlarkinIt could just be a clean room re-implementation of clojure
10:38AWizzArdRSchulz: Like &rest in Common Lisp.
10:38RSchulzYes. It makes perfect sense, but I don't think I've seen it before or thought of it. It's good to know, obviously.
10:38Chouserbinding does not support destructuring
10:38RSchulzRight. But does CL allow arbitray lamba lists in its let forms?
10:38AWizzArdok, so binding and def are special in that regard then
10:38drewolsonrfgpfeiffer: my brain hurts, but very cool
10:38jdzRSchulz: there is destructuring-bind
10:39AWizzArdRSchulz: CL does not do implicit destructuring if you mean this. There is.. what jdz said.
10:39RSchulzIn CL, you mean. I think I remember that, now.
10:40rhickeydanlarkin: this doesn't seem clean room: http://www.bitbucket.org/stefanrusek/xronos/src/tip/System.Xronos/Language/
10:41blackdogquite up to date though with atom and swap!
10:41Chouserrhickey: I'm not sure. The contents of the files seem very weakly informed by Clojure, if at all.
10:41rhickeyChouser: I agree, to the point of missing the point of persistent data structures in many cases
10:42Chouseryes
10:42gnuvinceWhat does a right arrow -> indicate in maths? Implies?
10:42danlarkingnuvince: if
10:42rhickeyAt some point there may be a proper targeting of the CLR from Clojure officially, making that effort moot
10:43Chouserrhickey: such that your objection, if any, should be over the mis-use of the name Clojure more than the mis-use of CPL code.
10:43RSchulzrhickey: How much attention have you paid to making a CLR-based Clojure possible?
10:43Chousers/should/could almost/
10:44ChouserRSchulz: early versions of Clojure targetted both JVM and CLR
10:44ChousukeRSchulz: if you look at the SVN history, there once was one :p
10:44RSchulzJust like Scala, yes?
10:44RSchulz(In that one regard!)
10:47AWizzArdmaybe in 1-2 years someone will start a Clojure version for .net
10:48rhickeyRSchulz: a CLR version is definitely possible, sans generics
10:49Chouserthis looks less clean room: http://www.bitbucket.org/stefanrusek/xronos/src/tip/System.Xronos/Reader.cs
10:49rhickeyheck, Chouser's got it running in JavaScript!
10:49RSchulzI guess that's a good thing. Did targeting the intersection of the two virtual machines impose any extra constraints on the language design?
10:49Chouserfor example, see line 19 and compare to line 44 of LispReader.java
10:50rhickeyRSchulz: the object models are almost identical
10:50RSchulzThat's trippy. Maybe when Chrome, with its supposedly super-fast VM, is mature, we can run Clojure directly in the browser.
10:50RSchulzActually, that's extremely cool.
10:51blackdogRSchulz, all major browsers except IE have the same performance characteristics in the latest betas
10:51blackdogin fact webkit is fastest right now i believe
10:51RSchulzSo Bill C's claim that CL is the Borg of languages will have to be supplanted by Clojure being the Borg of all languages. The one, true, universal programming language. All hail Clojure!
10:51rfgpfeifferRSchulz: my browser has a java plugin
10:52RSchulzGiven that JS VMs are only getting started, one can expect considerable improvement over the next few years. All very good.
10:52blackdogand Chouser's version compresses to 20K or so, so it's looking good
10:52RSchulzYeah, but the impedance mismatch of the Java browser plug-in makes it far from a good solution for most BBIs.
10:54rfgpfeifferis it possible to make applets with clojure now?
10:54Chouserrfgpfeiffer: almost. :-)
10:56rfgpfeifferis the applet class loader the problem?
10:57AWizzArdMaybe when applets work one can also write JavaFX apps.
10:57ChouserI think the problem is the security restrictions preventing Clojure from creating its own classloader.
10:58rhickeyhttp://richhickey.backpackit.com/pub/1597914
10:59rhickeyclojurebot: todo?
10:59clojurebottodo is http://richhickey.backpackit.com/pub/1597914
10:59rhickeyVersion 1.0 punch list there too
11:01RSchulzrhickey: Does the isa? implementation use a fast subtype hierarchy test? Or does it traverse the inheritance DAG?
11:02rhickeyRSchulz: it caches lookups
11:02rhickeyso fast
11:03RSchulzDoes it cache both positive and negative results on a argument-pair (per hierarchy) basis?
11:04stuarthallowaymorning all
11:04gnuvinceHi stu
11:04RSchulzHi stuarthalloway. Shouldn't you be writing something??
11:04rhickeyRSchulz: see MultiFn.java
11:04RSchulzrhickey: OK.
11:05stuarthallowaynot working on the book today -- I am porting the macro chapters of "On Lisp" into Clojure
11:05danm_nifty
11:05stuarthallowayand I have hit a snag :-)
11:05Chouserstuarthalloway: others have started on that -- not sure how far they've gotten.
11:05stuarthallowaywhen learning, it is ok to reinvent the wheel
11:06Chouserindeed
11:06stuarthallowaybut here is my question
11:06stuarthallowaypg has a variant of when-let that does not introduce a genysm for the bound symbol
11:06stuarthallowayClojure
11:07stuarthallowayintroduces a symbol (temp#) presumably to prevent double-evaluation
11:07mchurchI've got a question about the Clojure runtime. I know that SBCL's reader interns a symbol when it encounters it. Clojure seems not to do this; am I correct?
11:07RSchulzHow come every question I ask here is answered five minutes later as I listen to rhickey's Clojure for Lisp Programmer's talk?
11:08rhickeymchurch: kind of a trick question as CL's symbols are more like Clojure's vars, but yes, no interning by the Clojure reader
11:08stuarthallowaybut I cannot craft a scenario where this can possibly happen, because the destructuring kicks out anything that isn't a literal (line 2283 of core.clj)
11:09stuarthallowayRSchulz: and I double-dare you to find the video where rhickey has already answered my question :-)
11:09Chouserstuarthalloway: you're talking about his 'when-bind' ?
11:09stuarthallowayChouser; yes
11:09rhickeypaste please
11:09stuarthallowayrhickey: me?
11:10rhickeystuarthalloway: yes please
11:10mchurchrhickey: Ok, great. The reason I am asking is that I'm writing an RPC engine in multiple languages, and on the Lisp side, I have to serve out a package so as to avoid interning a bunch of garbage symbols.
11:10Chouserstuarthalloway: his doesn't double-evaluate -- do you need the capturing effect or something?
11:11mchurchWhich would, over the long term, have the effect of a memory leak. So you're saying that there's no need to worry about that with keywords/symbols, because an uninterned symbol will stay uninterned?
11:12stuarthallowayhttp://paste.lisp.org/display/72036
11:12rhickeymchurch: there's no such thing as an interned symbol, per se
11:13Chouserrhickey: are keywords not interened somewhere?
11:13stuarthallowaysorry so slow -- when I tried to choose #clojure at paste.lisp.org something went sideways
11:13stuarthallowayChouser: pg
11:13stuarthalloway(damn fat fingers) pg version expands ,var twice
11:14stuarthallowayClojure version avoids this, but I cannot see when it would be a problem
11:14rhickeyChouser: yes, keywords are, but not in a package. In CL, if you read (a b c) in 10 different packages you'd have 30 interned symbols, in Clojure 3 interned strings (the names of symbols are interned) and no lingering symbols
11:15Chouserbut that's just then name. Clojure uses temp# I think for destructuring.
11:15Chouserrhickey: ok.
11:15stuarthallowayChouser: convince me with a scenario where temp# is needed
11:15mchurchrhickey: So if the RPC engine gets hit with garbage keywords, there will be memory bloat?
11:16Chouserstuarthalloway: (defn foo [x] (when-let [[a b] x] (list a b)))
11:16rhickeymchurch: they'll hang around, yes
11:17mchurchrhickey: Ok, got it. Is there any way to get rid of them to trim the memory footprint?
11:20Chouserhttp://paste.lisp.org/display/72038 -- pg's when-bind
11:20mchurchI'm thinking about an engine with a lifespan of years, receiving many calls, so there's a lot of time for garbage to accumulate in the event of error.
11:22rhickeymchurch: it would probably require some kind of weak references on my end, would have to think about that
11:25stuarthallowayChouser: why not http://paste.lisp.org/display/72038#1? No temp#
11:28stuarthallowayMy contention is that the temp# if only needed if you can make the name side of the binding form have side effects
11:28stuarthallowaywhich my simple efforts have failed to accomplish because line 2283 of core.clj throws out any form that could possibly make trouble
11:29Chouserstuarthalloway: very good -- you've proved my example was insufficient. :-)
11:29ChouserTry this: (when-bind [[a & b] [1 2]] (list a b))
11:30Chouserso not a side-effect, but an expression that's a valid binding form but not a valid evaluation form.
11:30stuarthallowayChouser: terrific, thanks!
11:34RSchulzI thought you weren't writing today?
11:35stuarthallowayRSchulz: have absorbed more info from Chouser, must make changes :-)
11:36stuarthallowayactually I am going to have to draw a line somewhere. Does the issue we were just discussing really belong in a 225-250 page intro book?
11:37RSchulzWhat's the page limit you're operating under?
11:37Chouseryou're not going to make it in under 250 pages, are you?
11:37stuarthallowaymuch past 250 would change details for the publisher
11:37RSchulzI think you should try to beat the Programming Scala book. It's 736 pages...
11:37stuarthallowaythey're agile, they can deal, but they'll need to hear the voice of readers
11:37ChouserBy my count, 211 pages with 5 chapters to go.
11:38danm_736.. haha
11:38RSchulzI kid you not!
11:38stuarthallowaylike beloved reviewers clearly saying "book must have more coverage of X, Y, Z...." :-)
11:38blackdogbut clojure is succinct :P
11:39acieroidHi
11:39hiredmanRSchulz: but how much of that is just the type system?
11:39stuarthallowayI can't believe how inept I felt at Scala after reading those 736 pages. So ... much ... stuff ... I hope readers of the Clojure book won't feel that way.
11:39RSchulzYeah. That Scala... It's rococo
11:39Chouserstuarthalloway: to answer your question, I don't know that it does.
11:39acieroidwhat's the equivalent of lisp's append function with clojure ?
11:40RSchulzacieroid: into
11:40RSchulz(doc into)
11:40clojurebotReturns a new coll consisting of to-coll with all of the items of from-coll conjoined.; arglists ([to from])
11:40acieroidthanks
11:40acieroidnice bot :D
11:40RSchulzKeep in mind that depending on kind of collection given, the position of the added entries will vary.
11:40RSchulzThank hiredman for that.
11:40RSchulzclojurebot: hiredman?
11:40clojurebothiredman is slightly retarded
11:41duck1123clojurebot: botsnack
11:41clojurebotthanks; that was delicious. (nom nom nom)
11:41RSchulzI still think we're spoiling clojurebot.
11:41Chouserstuarthalloway: for it to matter, you'd need to (a) be writing a macro that (b) binds a form that is (c) user-supplied that (d) uses destructuring.
11:41hiredmanclojurebot: could you explain the nature of your creator?
11:41clojurebotexcusez-moi
11:41hiredmanhmmm
11:42Chouserstuarthalloway: and having lept those hurdles, you get a relatively clear "Unable to resolve symbol: &" error which can be resolved with one extra 'let'
11:43Chouserstuarthalloway: but clearly the book must have more coverage of seque. :-)
11:44rhickeyseque?
11:44Chouser(doc seque)
11:44clojurebotCreates a queued seq on another (presumably lazy) seq s. The queued seq will produce a concrete seq in the background, and can get up to n items ahead of the consumer. n-or-q can be an integer n buffer size, or an instance of java.util.concurrent BlockingQueue. Note that reading from a seque can block if the reader gets ahead of the producer.; arglists ([s] [n-or-q s])
11:44RSchulzThose funky "human transporters."
11:44Chouserrhickey?
11:44rhickeyChouser: I know what it does, just questioning its inclusion
11:45rhickeyis it really in there?
11:45rhickeyin the book?
11:45Chouseroh! just a joke. Having no coverage of seque is entirely appropriate.
11:45rhickeyright
11:45rhickeywhew!
11:45Chouser:-)
11:46rhickeyjust skimmed the macro section - I'd rather implement macros than explain them
11:46ChouserI carefully used exactly the same working as stuarthalloway's earlier commend about "beloved reviewers" and also added a smiley.
11:47Chouseryes! my blog post on 'doseq' was torture for me -- probably for readers as well. :-P
11:49rfgpfeifferrhickey: should the datalog from your todo be implemented in clojure
11:50rhickeyrfgpfeiffer: wrapper on http://iris-reasoner.org/ would be interesting too
11:52rfgpfeifferseque would make writing a parallel prolog solver in clojure very easy
11:52RSchulzDoes IRIS use a sound unifier?
11:53clojurebotsvn rev 1155; check for static field in classname/fieldname
11:54gpis eval the actual cloujure-interpreter? im doing genetic programming in both clojure and python and pythons eval seems somewhat limited, i cant def functions for example
11:55gpwhy does: (eval '((defn sq [x] (* x x)) (sq 12))) return 20736 (=12^4)?
11:55Chousergp: there is no clojure interpreter.
11:55gpcompiler?
11:55gpi thought interactive == interpreted
11:55Chouseryes, eval will compile and evaluate the expression.
11:56mehrheitgp: you call the function two times there
11:56ChouserI know, it's cool, right? Each thing you type at the repl is complied to bytecode on the spot and handed off to the JVM to run.
11:57mehrheitgp: (F ...) is a function call, defn returns the defined function (the var more exactly, but the behavior is the same in this case) which occurs in the function position of the list you pass to eval
11:57mehrheitgp: so you get (sq (sq 12))
11:57gpah i see (eval '((defn sq [x] (* x x)) 12))
11:58mehrheitgp: it should probably be (do (defn sq ...) (seq 12)), since do sequences operations
11:58mehrheiterr, s/seq/sq
11:58hiredmanor use fn instead of defn
12:05gphmm i cane val anything it seems so it is more complete than pythons eval
12:05Chousergp: python splits expressions and statements. Clojure does not.
12:08Chousergp: to work with python statements you'd have to use compile() and have to specify 'exec', 'eval', or 'single'
12:09rfgpfeiffergp: eval is a function that evaluates expressions, so it can be used in another expression
12:09rfgpfeiffergp: exec is a statement
12:12gpi see
12:13gpsingle?
12:21gpi found out
12:21gpwell it seems Python complicates that part a lot. I did genetic algorithm in python but seems for genetic programming lisp is the sh*t
12:36PupenoHello.
12:37Pupenowhat do we have in terms of unit-testing frameworks?
12:42Lau_of_DKPupeno: Kotarak is working on something, check the GoogleGroup
12:45Chouserthere's clojure.contrib.test-is
12:47stuarthallowayPupeno: I have been playing with Fact today: http://paste.lisp.org/display/72042
12:47stuarthallowayDescription of Fact: http://groups.google.com/group/clojure/browse_thread/thread/193023afbf87698d
12:47stuarthallowayI hope to post a blog entry later explaining that example
12:49mchurchDoes Clojure have a TRACE facility?
13:06danlarkinmchurch: there's one in contrib and IIRC there was one posted to the group recently too
13:11danlarkinPupeno: I like clojure.contrib.test-is
13:12durkamchurch: clojure.contrib.trace
13:12durkadefn --> deftrace
13:17notyouravgjoelAm I doing anything wrong by running "java -cp jline-0.9.94.jar:clojure.jar jline.ConsoleRunner clojure.lang.Repl"? the current directory has bothy jline-0.9.94.jar and clojure.jar
13:22notyouravgjoelughhhh
13:22notyouravgjoelnm
13:34RSchulznotyouravgjoel: What platform do you use?
13:35notyouravgjoelgot it fixed =)
13:35notyouravgjoelbut, for reference, I'm on windows right now
13:35RSchulzOK. But if you're on Linux (or maybe Mac, too), I recommend rlwrap over jLine.
13:35RSchulzProbably rlwrap works on Cygwin, too, but I don't really know.
13:57AWizzArdIn there something like CLs integer-length in Clojure/Java?
13:57AWizzArdhttp://www.lispworks.com/documentation/HyperSpec/Body/f_intege.htm
14:02rfgpfeifferlogarithms?
14:02rfgpfeifferbase 2
14:03AWizzArdThere is an example implementation in the HS.
14:04AWizzArdBut maybe Java already has something like that.
14:13acieroidhum
14:13acieroidwith other lisps than clojure, when there is an error on the evaluation, slime put the error buffer on the screen
14:13acieroidbut not with clojure
14:14acieroidso I have to C-x b every time :x
14:15drewrThat might not be implemented yet.
14:15acieroidok
14:18acieroidwhat's the default namespace ?
14:18drewrThere isn't really one. I suppose user is the closest thing.
14:19acieroidbut, if I use in-ns, and then try to use a simple function like +, it doesn't work
14:19hiredmanacieroid: you need to refer clojure.core
14:19acieroidah
14:19acieroidI tried clojure, not clojure.core
14:20hiredman(clojure.core/refer 'clojure.core)
14:20hiredmanit got renamed
14:20acieroidyes, thanks
14:20drewrAh, yes. The clojure namespace. :-)
14:23acieroidclojure is very nice btw, I really like it :)
14:28drewracieroid: I do too.
14:34gpclojure is the shiznit
14:51gpif i wrap loops will the vars be reassaisned then?
14:53gpor i have to recur back to the oute rloop hmm
14:59stuarthallowayOn Lisp -> Clojure, chapter 7: http://blog.thinkrelevance.com/2008/12/12/on-lisp-clojure-chapter-7
14:59stuarthallowayfeedback welcomes
15:00stuarthallowayJavaScript library that syntax-colors Clojure correctly would also be very welcome
15:01Chousukewell there's one used on clojure.org ... I remember seeing the config for that somewhere :/
15:01Chousukeunfortunately I don't remember WHERE.
15:06billcstuarthalloway: Have a look at the Clojure site's one: http://clojure.org/file/list (clojure.js, code_highlighter.js, et al)
15:06stuarthallowaybillc: thanks, will do
15:06clojurebotsvn rev 1156; fixed tagToClass for chars
15:54danm_is merge the appropriate way to update a map?
15:55drewrdanm_: It's how I do it. You can use conj too.
15:55danm_to associate a key with a different value?
15:56drewrSure.
15:56drewruser> (conj {:foo 1} {:foo 2})
15:56drewr{:foo 2}
15:56danm_ok
15:56danm_thanks
15:56danm_I suppose I could have typed that at the repl
15:56drewr;-)
15:57danm_I'm trying to create an in memory database, and I can't help but feel as though I'm fighting the current, so to speak
15:57danm_side effects, oh my
15:58drewrPaste some code and maybe we can help.
15:59drewrhttp://paste.lisp.org/new/clojure
16:00danm_thanks
16:03danm_hmm, goes to http://paste.lisp.org/submit and it's a blank screen
16:03danm_no actibity
16:03danm_activity :P
16:03Chouseryeah, sometimes the channel-assignment thing breaks. go back and choose "none"
16:03danm_ok
16:03Chouserthen post the url here manually
16:04danm_http://paste.lisp.org/display/72062
16:04danm_thanks
16:06danm_dq is a structmap
16:06danm_emacs gets really slow when I run that function 2230times ;)
16:07Chouseryou can use 'alter' there, instead of 'ref-set', or probably even 'commute'
16:08danm_obviously, have a few things to learn about refs and such
16:08danm_thanks
16:08drewrYou can also use (dq :date). Maps are funcallable.
16:10Chousukeor (:date dq) ;)
16:11danm_drewr: ahh, sweet
16:11danm_(apply list (line-seq buf))
16:12danm_where buf is a buffered reader reading an input stream from a url
16:12danm_is there something braindead about doing it that way?
16:12Chouserno, but why stick it in a list?
16:12drewrline-seq already returns a seq, which means you can do all sorts of things that listy.
16:13drewrthat are
16:13danm_well, because when the function returns the stream gets closed
16:13danm_with-open
16:14drewrHm. I had that issue with a ResultSet macro the other day.
16:14drewrI ended up doing (into {} (resultset-seq ...)) to accomplish the same thing.
16:15danm_thanks for the help
16:16triddellIs there a library/approach in clojure for creating xml? Groovy has a builder syntax which make is very easy to generate xml/xhtml and I wanted to port some of this to clojure.
16:18clojurebotsvn rev 1155; check for static field in classname/fieldname
16:18clojurebotsvn rev 1156; fixed tagToClass for chars
16:18hiredmangrrr
16:18gpOne thing I find annoying with dynamic languages is that I find a need to dicument types. like I might want a descriptive name but to really describe what should be passed then I need ridiculous names for variables like all-vars-all-values-vector-map
16:19drewrgp: metadata.
16:19Chouseror comments
16:19Chouseror doc strings
16:19hiredman"pass in whatever works"
16:19drewrOr DWIM. :-)
16:20triddellalso, to clarify, when I said "port", I meant port existing code that used this Groovy feature to clojure, not port this functionality to clojure (if something like it doesn't exist)
16:21gp(defn f "docstring" [args] ...) right? where do i stash metadata?
16:22drewrtriddell: There's no xml-generating code yet that I know of. I've made my own around javax.xml.
16:22drewrIt'd be great to have something functional that's standard.
16:23gpis there a way to have default/optional arguments? like in python def f(x,y=10): ...
16:24triddelldrewr: thanks, I hadn't seen anything yet (in irc or on the list) but I also wasn't really looking until now
16:24drewrgp: Look at http://clojure.org/special_forms
16:25drewrgp: For the metadata, not for default args.
16:25drewr(defn foo #^{:bar :baz} :quux)
16:26mfredricksonclojurebot: keyword arguments?
16:26clojurebotkeyword arguments is http://groups.google.com/group/clojure/msg/51bb53ca077154f8
16:26mfredricksongp: see clojurebot
16:27mfredricksonothers can confirm, but clojure maintains Java's function call interface, so no keywords/defaults
16:28mfredricksonyou could roll your own ruby style by passing in a hash as the last argument by convention
16:31Chousertriddell: there are a few ideas mentioned here: http://groups.google.com/group/clojure/browse_thread/thread/ab7a6a7a14575a96/55565925939312b3
16:31Chousertriddell: here's one http://github.com/mmcgrana/clj-html/tree/master
16:32Chouserthere are other ones around... one in webjure, another in compojure.
16:33Chouserthe thing is, it's pretty easy to write a simple, slow, weakly-featured template library in Clojure, so many of us have done just that. :-/
16:33triddellI'll check those out. thx
16:36AWizzArdChouser: this posted example uses a template engine that went wrong, like so many others.
16:37AWizzArdBecause it allows you to put code into the template.
16:37AWizzArdThis means that people will do it.
16:38hiredmanI really like compojure's html generating dingus
16:38ChouserAWizzArd: The only way to avoid that is with a new non-clojure language, right?
16:38AWizzArdRifes engine for example has really no logic at all embedded, not even presentation logic, which is a fine thing imo.
16:39hiredmanyou make vectors and (html ...) turns it into html
16:39AWizzArdthat would all be done in Clojure, presentation logic and business logic
16:40AWizzArdhiredman: that would be okay, to have s-expressions instead of the html stuf
16:40AWizzArdalthough s-expressions are only a subset of what html can do. But usually for most cases this should be okay.
16:41AWizzArdChouser: well, html already is something different than Clojure. I just mean I want not a single bit of logic inside the templates, which should be... templates.
16:43hiredmanyou could do that with compojure's (html ...)
16:44AWizzArdwhen writing strings you mean?
16:44hiredmanmake a function returns a template with a bunch of vars in it, and wrap it in a binding
16:44AWizzArdoh I see
16:44hiredmanAWizzArd: html == strings
16:44hiredmanwhat are you talking about?
16:45AWizzArdI first thought you were talking about s-expressions being a subset of, dunno, "html-expressions"
16:45AWizzArdbut that would still not be the right thing, because then template stuff would be in the code
16:45AWizzArdin the function that emits templates
16:45hiredman...
16:46AWizzArdNo template stuff in the code, no html in the code ever, no logic in the templates. I think this is the most clean way to do it.
16:47hiredmanit will, infact, emit html
16:47hiredmannot templates
16:47hiredmancompojure's (html ...) takes a vector and emits html (also there is (xml ...))
16:47gpif i ant toloop over a range and for each loop conj somethig to a vector, which construct do you use then? loop-recur or reduce?
16:48AWizzArdhiredman: I don't say that this is a bad thing. I just think this is not the best way to do it. The Pretty Home Page language (php) started off like that. It was their killer feature to be able to have code in the html. Soon this made things more and more complicated, and frameworks like smarty (and others) were developed, to go away from this direction.
16:49hiredmanAWizzArd: oh, compojure is not like at all
16:49hiredmanthere is no code in the html
16:49hiredmanthere is not html, until you run (html ...) on a vector
16:49hiredmanthen you just have this string of html
16:49AWizzArdI see
16:50AWizzArdalthough you can't compose all valid html strings with it
16:50hiredman(defn tpl [] (html [:html [:head] [:body foo]]))
16:51hiredmanthen (binding [foo "something"] (tpl))
16:51AWizzArdyes, nicer than pure html for many things
16:51hiredmanfor just about everything
16:51hiredmanhtml bites
16:51triddellI just looked at the html library in compojure and I think that will do what I need. I don't need templates... just need to code generate xhtml/xml dynamically from existing data.
16:52AWizzArdhiredman: could it also do something like <B>Hello <I>people from</B> New York</I> city.
16:52mehrheitisn't that invalid?
16:52AWizzArdfor xml invalid
16:52AWizzArdfor html it's okay
16:53mehrheitweeh
16:53hiredmanAWizzArd: but you can get the samething by doing it sanely
16:53AWizzArdyes
16:53AWizzArdand it's rare
16:53hiredmanso what is the point of the garbage?
16:54AWizzArdJust an example that html can express more than s-expressions.
16:54AWizzArdIn 99% of the cases it's tons of boilerplate code, to explicitly have this closing tag. But for rare cases it allows some more expressivity.
16:55hiredman...
16:55hiredmanhow?
16:55AWizzArdAs in the example that I gave above.
16:55hiredmanhow is doing it that way more "expressive" then doing it the sane way?
16:55AWizzArdHow is Clojure more expressive than coding assembler?
16:56AWizzArdof course, they all can produce equivalent results
16:56mehrheitin one way, by imposing certain rules, so that you cant express insane things
16:57hiredmananyway
16:57mehrheitand therefore have more space for useful things
16:57hiredmangood lick with that
16:57hiredmanluck
16:58hiredmanugh
17:02AWizzArdDo you mean space as in number of chars?
17:02AWizzArdlength of lines?
17:03mehrheitbasically, yes
17:06AWizzArdWell, in that aspect Lisps traditionally also don't shine. The s-expression style needs lots of whitespace in front of where the code usually starts. The strength is really the code=data part.
17:07AWizzArdhiredman: this small description already explains more or less all there is about templates in Rife. The logic can hopefully soon be implemented completely in Clojure: http://rifers.org/wiki/display/RIFE/GuideTemplates
17:08mehrheitthen keypresses would fit better; with a good editor indentation is zero keypresses
17:10AWizzArdYes, that's right. I just mean that it gives us a lot of weakly used space.
17:11mehrheitI don't think thats a lot of space
17:12AWizzArdokay, that's an opinion
17:14gpanyone know a good place where you can host your webapss for free?
17:14gpjust a small one, dont need any space tos tore stuff, just want show a demo.
17:24Chousermy gen'ed class that extends Applet includes this method for no reason that I can find: public void net.n01se.Tree.applyCompoundShape(sun.java2d.pipe.Region)
17:24ChouserI can't find it in any of the supers of my class
17:25Chousera web search finds it in docs for java.awt.Window, but java.awt.Window's not in my supers and doesn't appear to actually have that method.
17:44clojurebotsvn rev 1157; removed sharing in registerConstant
17:51RSchulzChouser: Which JDK version are you using?
17:52Chouserjava version "1.6.0_0"
17:53ChouserI think it may be picking up that method from ComponentPeer, somehwo
17:53Chousersomehow
17:53RSchulzApplet's got a pretty deep inheritance hierarchy.
17:53Chouseryeah, but I searched it.
17:53RSchulzI was thinking it might be an implementation-specific thing, like something that comes from a browser tie-in.
17:54Chouser(map (fn [c] (filter #(= (.getName %) "applyCompoundShape") (.getMethods c))) (supers net.n01se.Tree))
17:54Chouser(nil nil nil nil nil nil nil nil nil)
17:55Chouseranyway, I added an :excludes option to genclass and that seems to get me past the security warnings for appletviewer.
17:55Chouser...now it just does nothing at all. :-P
17:55RSchulzOddly enough, IDEA's symbol lookup can't find apployCompoundShape (or applyCompound*) anywhere in my 1.6.0_11 JDK.
17:55RSchulz(Or even the properly spelled name...)
17:56RSchulzDid you really mean 1.6.0_0 ??
17:57Chouserjava version "1.6.0_0"
17:57ChouserOpenJDK Runtime Environment (build 1.6.0_0-b11)
17:57ChouserOpenJDK Server VM (build 1.6.0_0-b11, mixed mode)
17:57Chouserhm... openjdk maybe?
17:58RSchulzDo you recall a post you made to the Clojure list in late July, subect "gen-class patch" net.n01se shows up there.
17:58RSchulzAnd here: http://paste.lisp.org/display/68406
17:58Chousersure -- that's a domain I use.
17:58RSchulzAre you sure this isn't some cruft that's specific to your setup?
17:59RSchulzOK. So a red herring then?
17:59Chouserah. yeah, pretty sure.
17:59RSchulzBut the thing is, that applyCompoundshape would appear to belong to one of your classes, then.
18:01Chouserwell, gen-class is adding that method to my class, yes. The question is why?
18:01RSchulzPerspicacity?
18:01RSchulzOr is it perspicuousness?
18:01RSchulzThe second one.
18:02gprhickey: cant you add sum (reduce + coll) and enumerate(enumerate ["a" "b" "c"] -> [["a" 0"] ["b" 1] ["c" 2]]) to Clojure? i would guess a lot of people have it in their user.clj...
18:02RSchulzNo. The first one.
18:02Chousergp: enumerate is called clojure.contrib.seq-utils/indexed
18:04gpChouser: cool
18:22gpanyone can point to the link with monads in clojure?
18:24acieroidhmm, is there a function like lisp's format, to do some showing operations on lists (like (format t "~{~a ~}" '(some list))) ?
18:25acieroid(and that can be applied to vectors)
18:27ChousukeI think someone was working on an implentation.
18:28acieroidm'kay
18:29Chousukehttp://github.com/tomfaulhaber/cl-format/tree/master here's one
18:30acieroidthanks
18:37ben1i know a little scheme, but no java; where's the best place to learn clojure?
18:38acieroidhttp://writingcoding.blogspot.com/2008/06/clojure-series-table-of-contents.html is a nice example
18:38hiredmanyou don't have to learn too much java, but you need to learn to read javadoc
18:39ben1acieroid: looks good
18:39ben1ok, i'll try
18:39ben1thanks
18:39hiredmanhttp://java.sun.com/javase/6/docs/api/java/lang/String.html
18:40hiredmanbut, uh, you will need some java to read javadocs
18:43ben1hmm, for some reason (re-seq #"\\w+" "This string contains some tokens. Yipee!") outputs nil for me
18:43zakwilsonben1: I'm a Lisper with no real Java experience and I've been able to pick it up reading the Clojure and Java documentation.
18:43Chouserben1: #"" rules have changed. for recent clojure, don't double-backslash
18:44ben1ah i see, thanks
18:45gplol im writing imperative in clojure: (let (let (let (let (let ...
18:46hiredman:(
18:46hiredmanyou could most likely move that all into a single let
18:48karmazillacan a single macro expand into two defs? my goal is easily defining functions that execute only once regardless of how many times they're called
18:48hiredmankarmazilla: yes
18:48Chouserkarmazilla: sure -- wrap a (do ...) around them
18:48hiredman^-
18:50karmazillasuper! thanks
18:50RSchulzkarmazilla: That, or get Stuart Halloway's Programming Clojure book, where this precise example is covered in detail.
18:51RSchulzThat book is in pre-release and available in PDF form.
18:51RSchulzFrom Pragmatic Programmers.
18:52karmazillado you remember what the example is called?
18:53zakwilsonkarmazilla: see also the memoization example in the documentation for atoms.
18:53RSchulzIt is the runonce feature needed for his Lancet (Ant driver) program.
18:54RSchulzSection 6.4: "Making Lancet Targets Run Only Once" (page 141 in beta4 of the PDF)
18:56ben1why doesn't (map .toLowerCase '("This" "IS" "my" "name")) work?
18:57RSchulz.toLowerCase isn't a Clojure function
18:57RSchulzTry this: (map .toLowerCase '("This" "IS" "my" "name"))
18:57RSchulzWoops!
18:57RSchulzHang on.
18:57ben1but (.toLowerCase "fOo") works
18:57RSchulz(map #(.toLowerCase %) '("This" "IS" "my" "name"))
18:58ben1ok that works
18:58hiredman. does some special reader magic
18:58ben1so how do i know when i can use ".toLowerCase"?
18:59RSchulz.JavaFieldOrMethod is a special form.
18:59RSchulzActually, that's only true of ., not of .stuff
18:59hiredmanmostly in (.f a) or in any place that turns .f into (.f a)
19:00hiredmanso you can use .f in ->
19:00hiredmanmaybe the new doto, I don't recall
19:00RSchulzWhat's that? Iget only a missing-glyph symbol.
19:00hiredmangrrr
19:00hiredmanan irssi auto replace run amok
19:00hiredman->
19:00hiredmangah
19:01hiredmanthe arrow deal
19:01RSchulzIs that the same thing that turn my less-than into <
19:01Chousukeben1: .foo can only appear as the operator in a form right now.
19:01RSchulzEh? Sometimes I get &lt; when I paste <
19:01ben1Chousuke: ok thanks
19:01Chousukeben1: of course, there are macros that make that appear untrue
19:01hiredmanlike (->)
19:01Chousukeor doto
19:03RSchulzOr ..??
19:03RSchulz(..)
19:03Chousuke.. is meh.
19:03Chousuke-> is better
19:04Chousukethough I remember rhickey mentioning that he might implement "auto-memfn" for .forms, so you might eventually be able to use map etc directly with java methods.
19:05Chousukefor now, just use #(.foo %) or (memfn foo)
19:13karmazillahow do people normally build (as in compile + test + package) clojure programs?
19:15danlarkinHm this is confusing me... javadoc for an object says it should have a method... method is listed when I use (show obj) but when I try (.method obj) it says no matching method found
19:17Chouserdanlarkin: that error is also used if the arity or arg types don't match.
19:18danlarkinChouser: it has arity zero, http://jparsec.codehaus.org/jparsec2/api/org/codehaus/jparsec/Terminals.html#tokenizer()
19:19Chouserhm. Have you tried my 'show' function?
19:21Chouseror (filter #(= (.getName %) "tokenizer") (.getMethods (identity org.codehaus.jparsec.Terminals)))
19:23danlarkinhttp://dpaste.com/98647/
19:23Chouserwow
19:23RSchulzShow is fab!
19:24danlarkinconfusing right?
19:25Chouser(.isBridge (show operators 18))
19:26danlarkinfalse
19:28Chouserwell, I'm stumped. :-)
19:29danlarkinrhickey: care to weigh in?
19:30jonafandoes clojure have a unit testing framework?
19:31jonafanprobably a dumb question
19:31danlarkinjonafan: clojure-contrib does
19:31jonafancool
19:31jonafani'm trying to decide what language to learn in 2009
19:31danlarkinjonafan: clojure :)
19:32gnuvince_jonafan: what's on your list?
19:32jonafanhehe
19:32Chouserhttp://clojure-log.n01se.net/date/2008-12-12.html#12:36 -- unit test question
19:32jonafanforgive me if i consider your answer some what biased
19:32jonafanclojure, erlang, haskell, forth, smalltalk
19:32gnuvince_Good choices
19:32gnuvince_(though I'd change Forth for Factor)
19:33jonafanmaybe
19:33danlarkinfor all the hype that smalltalk gets I really dislike it
19:33Chouserjonafan: I started on Scala this year, but that only lasted a couple months. I'll be on clojure for a while...
19:33gnuvince_Factor, Clojure and Haskell would be my recommentations.
19:33gnuvince_Not necessarily in that order
19:33gphow Is Factor interesting?
19:33gpDepending on where you come form I think Haskell is the most mindexpanding.
19:34jonafanin 2008 i learned ocaml
19:34ChouserIt'd be useful to be able to read Haskell.
19:34gnuvince_gp: many ways: it's a very minimal and powerful language, the implementation is getting extremely good, and it can teach you to think in terms of stacks.
19:34jonafanhaskell is stricter and has monads, but they are pretty similar languages
19:34gnuvince_Haskell is lazier
19:34jonafanokay, haskell is lazier
19:34jonafani meant in terms of purity
19:35gnuvince_jonafan: in any case, your list is a very good one.
19:35kib2no one for Rebol ? it's awesome, really.
19:35Chouserjonafan: have you done any lisp before?
19:35gnuvince_Any one of those languages is gonna be better than another newbie learning PHP or C.
19:35jonafani had scheme in college
19:35Chouserjonafan: Clojure won't take you a year. :-)
19:35gnuvince_Clojure would therefore bring something new.
19:35jonafani loved it
19:36gnuvince_Try Clojure
19:36gnuvince_It's fun :)
19:36jonafanyeah, but i don't want to learn it and not use it for anything
19:36zakwilsonClojure would be my pick of those for getting things done.
19:36jonafani want to learn it and use it for whatever i feel like coding during the year
19:36zakwilsonFactor or Haskell would probably twist your mind around more.
19:36zakwilsonThough that depends on your background.
19:37gnuvince_jonafan: Clojure with the huge Java lib would definitely allow you to do things
19:37jonafancoming from ocaml, i don't feel like doing haskell yet
19:37zakwilsonjonafan: Do you have experience with Java?
19:37jonafanyeah
19:37gnuvince_Go for Clojure ;)
19:38zakwilsonYeah, what gnuvince_ said.
19:38jonafani definitely feel like clojure is cooler than erlang
19:38gnuvince_Oh definitely
19:38Chouseryou can probably getenough clojure under your belt by June to be able to dismiss the rest by the end of the year.
19:38zakwilsonWhat you already know about the Java lib, classpaths, jars and the like will carry over.
19:39Chousukeclojure is probably somewhat a gentler introduction to FP than haskell
19:39gnuvince_I don't think he needs an intro
19:39gnuvince_he knows OCaml
19:39jonafanand scheme
19:39Chousukeah, well that'll do
19:39zakwilsonIf you know OCaml, Scheme and Java, it should be very easy to pick up Clojure and start making useful things.
19:39gnuvince_jonafan: have you seen my (still incomplete) tutorial?
19:40jonafannot yet
19:40jonafani watched a presentation rhickey did and ran some related code
19:40jonafaninvolving some ants finding a path to food
19:41Chousukemake sure to use a recent SVN checkout instead of the release version though.
19:41gnuvince_yeah
19:41jonafani don't know, i'm still deciding
19:41gnuvince_jonafan: his presentations are awesome
19:41gnuvince_Anyway, what's the worst that could happen?
19:42jonafanthe only thing i am concerned about is the relative immaturity of the language
19:42jonafanmaybe it is fine, but there is no doubt that the other languages are more mature
19:42gnuvince_Fear not, it's progressing along very nicely and the implementation keeps getting better at a very fast pace.
19:42zakwilsonThere is that, and breaking changes do happen.
19:43zakwilsonOn the other hand, the Java library is very stable.
19:43gnuvince_I can tell you that the Smalltalk experience is somewhat... lacking
19:43ChousukeI think most of the breaking changes have already been done
19:43gnuvince_Squeak isn't too hot, VisualWorks either
19:43ChousukeAOT and gen-class
19:43gnuvince_Erlang still has no unicode support.
19:43jonafansmalltalk is a language that i have always felt like i should learn
19:43rhickeydanlarkin: looks like something is lying, probably the JavaDoc? as notice: org.codehaus.jparsec.Lexicon.tokenizer(), but javadoc says derived from Object, no interfaces
19:44gnuvince_I don't think Clojure is behind the pack.
19:44gpis there no infintiy in Clojure?
19:44rhickeydanlarkin: i.e. tokenizer is not declared in Terminals
19:44jonafananyway, i'm going home
19:44gnuvince_gp: (/ (float 1) (float 0))
19:45gpI tried Smalltalk/Squeak once and started ona tutoria but I never really got anywhere, the whole this-language-is-also-an-OS wasn't my thing. Not that I gave it that much time.
19:45RSchulzOr, more directly (Float/POSITIVE_INFINITY)
19:45RSchulzLikewise for Double
19:46RSchulzAnd NEGATIVE_INFINITY
19:46gpI find Clojure to be very mature for its age. When is 1.0 planned anyway?
19:47zakwilsonWhy is (/ 1.0 0.0) not the same as (/ (float 1) (float 0))?
19:47Chousukezakwilson: 1.0 and 0.0 are Doubles
19:47gnuvince_What he said
19:47danlarkinrhickey: I see
19:47RSchulzI agree. Considering its chronological age, Clojure is quite advanced. That's because of Rich's diligence and the platform support provided by the JVM.
19:48danlarkinrhickey: but (filter #(= (.getName %) "tokenizer") (.getMethods (identity org.codehaus.jparsec.Terminals))) does return a Method
19:49mfredricksonRSchulz: I also think (and this is entirely my opinion) Clojure has _greatly_ benefits from learning from the mistakes of others (CL and Scheme specifically). This is entirely to rhickey and other contributors credit, but let us not forget those that have gone before. :-)
19:49rhickeydanlarkin: but it is coming from a superclass and it's callability is dependent upon that, if nothing else for troubleshooting I'd need to know the access level of that class/interface etc
19:50mfredricksonfrom my position, Clojure fixes all the little irritations I have with Scheme without being too heavy handed
19:50mfredricksonnot that I wouldn't like continuations and TCO again.
19:51Chousukeheh
19:51Chousukemaybe we'll have all that cool stuff in clojure 2.0 someday :P
19:51mfredricksoni'm in no hurry
19:51Chousukea lot depends on the JVM too
19:51mfredricksoni like the design to choice to leave out broken features
19:52mfredricksonChousuke: my understanding as well
19:53ChousukeJVM quirks seem to be the cause of some "warts" in clojure, but I think the benefits are worth a few compromises.
19:54danlarkinrhickey: is that information I can provide you? not sure what the access level is/means
19:55mfredricksonChousuke: I think that is basically the value proposition of clojure: a lisp that is willing to make compromises. worse is better while still being better, if you get my drift
19:55mfredricksoni realize that could describe a lot of lisps. I need to refine that
19:57Chousergah, Java is frustrating. Staring at the docs to a class, and still don't have any clue how to create one.
19:59replaca /win 1
20:00Chousukehmh, maybe clojure is a functional programming language not just in the mathematical sense :)
20:03mfredricksonlet's see what clojure bot has to say on the matter
20:03mfredricksonclojurebot: clojure?
20:03clojurebotclojure is a very attractive hammer with a nice heft to it
20:03mfredricksonthere you are
20:04gpChouser: ol often have the same problem, Java is so ridic bloated. Funny thing it is so well documented and still it is hard to figure out how to do simple stuff like just calling a class.
20:10Chouserdanlarkin: well, Terminals inherits tokenizer from Lexicon, but that doesn't help me see what's failing.
20:12Chousukegp: I find the problem to be often that while the information is there, it's usually in bits and pieces all over, because when you need to use a class to do something, that class uses other classes, and those use yet again other classes, et cetera
20:12Chousukeso you end up having to dig through a lot of documentation.
20:17rhickeyChouser: is Lexicon public? Is there JavaDoc?
20:18gpChousuke: yes that was "head on the nail" or how you say it.
20:24ChouserI don't see any javadoc for it.
20:25rhickeyChouser: how are you looking into this?
20:27Chouserwhat I know about Lexicon: http://paste.lisp.org/display/72076
20:28Chouserso clearly the javadoc is lying at least about "extends"
20:29rhickey(.getModifiers (identity Lexicon))
20:31Chouser0
20:33rhickeyChouser: !?
20:33Chouserhttp://paste.lisp.org/display/72076#1
20:34rhickeyI believe you :), just confused
20:34danlarkin0 for me also
20:34ChousukeChouser: is show in contrib or just floating on the web somewhere?
20:34rhickeynot public, protected or private - must be package?
20:36rhickeyis the source for this somewhere?
20:36ChouserChousuke: I guess I should put it in contrib.
20:36Chouserback in a bit
20:36danlarkinrhickey: http://jparsec.codehaus.org/Downloads
20:38Chousukeoh crap
20:38Chouserclojurebot: show?
20:38clojurebotshow is http://groups.google.com/group/clojure/msg/96ed91f823305f02
20:38ChousukeI hope I have backups...
20:38Chousuketime machine is a bit quirky sometimes :)
20:38RSchulzWhy this:
20:38RSchulzuser=> (.getModifiers java.lang.String)
20:38RSchulzjava.lang.NoSuchFieldException: getModifiers (repl-1:21)
20:39RSchulzAnd this:
20:39RSchulzuser=> (.getModifiers (identity java.lang.String))
20:39RSchulz17
20:40ChousukeRSchulz: the former tries to call java.lang.String.getModifiers
20:40Chousukethe latter calls .getModifiers on the Class object
20:40RSchulzAh.
20:40Chousukebut, hooray, I had backups.
20:41RSchulzStill, given what (identity) does, it's perhaps justified that one is surprised by this result...
20:41Chousukewell, identity just works around the fact that (.foo Classname) assumes you're calling a static method rather than a method with the Class as the argument
20:42RSchulzYes. But since (identity ...) "does nothing", it's still a bit perplexing.
20:42rhickeyclojurebot: faq #1?
20:42clojurebotI don't understand.
20:43rhickeyclojurebot: faq?
20:43clojurebotPardon?
20:43danlarkinclojurebot: FAQ #1
20:43clojurebotFAQ #1 is http://groups.google.com/group/clojure/msg/8fc6f0e9a5800e4b
20:43rhickeyRSchulz: ^^
20:43RSchulzclojurebot's case-sensitivity is a dubious feature...
20:44RSchulzOK. Got it. But it just emphasizes the precariousness of syntactic sugar.
20:47RSchulzClarify, if you will: Does the interpretation of dot / (. ...) depend on whether there's any white-space after it?
20:48RSchulzFor example, is (. foo could be bar) different than (.foo could be bar)?
20:48danlarkin(.method obj) is equivalent to (. obj method)
20:49Chousukeso (. foo could be bar) is (.could foo be bar)
20:49RSchulzOK. That's one of the more tortured syntactic sugarings, no?
20:49Chousuke. should go away ;(
20:50rhickeyRSchulz: only when you choose meaningless names
20:50RSchulzSeriously?
20:50rhickeyhow is it tortured?
20:50RSchulzHmmm....
20:51rhickey(. target method arg)
20:51rhickey(.method target arg)
20:51RSchulzOrder matters. A single period and a single space necessitates an alteration of the order of the arguments (punctuation aside)?
20:52RSchulzActually, just the space...
20:52rhickeyRSchulz: necessitates is pejorative, this is a feature - lispy method call start with the verb
20:52rhickey.blah is one symbol
20:53RSchulzI certainly don't mean "necessitates" to be perjorative, but it's ... fragile? (That seems more perjorative.)
20:53Chouserspaces matter in almost all languages. this really doesn't bother me.
20:53RSchulz(But I can't help mention that Clojure has a non-white-space white-space symbol...)
20:54Chousukeheh
20:54rhickeyRSchulz: it's easiest to understand as macrology, .blah is inherently a macro:
20:54rhickeyuser=> (macroexpand '(.getMethods String))
20:54rhickey(. String getMethods)
20:54Chousuke(.,I,can,mess-you,up)
20:54RSchulzWhich is to say that . followed immediately (no white-space) by a symbol is a metalinguistic schema.
20:55rhickeyRSchulz: no, .blah is one symbol
20:55rhickeya regular symbol
20:55RSchulzExactly! "I can mess you up." would still be understood as the same as "I,would,mess,you,up"
20:55RSchulzI understand, but visual comprehension matters, too.
20:56Chousukeso does the reader work so that it reads ".read" and passes the *symbol* to the reader-macro-magic that transforms it?
20:56RSchulzAnd when a single space combined with a swapping of adjacent symbols yields the same thing, that's a bit ... unexpected.
20:56rhickeyt u v and tuv are different, big deal
20:57rhickeysame as all lisps, whitespace delimited
20:57ChousukeRSchulz: don't forget about the third dot :)
20:57RSchulzHow many times have you seen a spurious space before a comma or a period. Did it make you misinterpret the sentence?
20:57Chousuke(String.) :P
20:57ChouserRSchulz: just don't use (. obj method) format. It's unnecessary.
20:57RSchulzI'm inclined to go with that, Chouser
20:58RSchulzAs long as my cat doesn't hit the space bar while I'm not looking.
20:58Chousukeand for static calls/fields, use / :)
20:58RSchulzDivision?
20:58Chousukeno, as in Math/PI
20:58RSchulz... That was meant as humor...
20:59Chousukesorry, it's late :p
20:59rhickeyCl-USER 6 : 1 > (length '(a.b))
20:59rhickey1
20:59rhickeyCL-USER 7 : 1 > (length '(a . b))
20:59rhickeyError: In a call to LENGTH of (A . B), tail B is not a LIST.
20:59Chousukeor actually, it's almost morning ;(
20:59RSchulzOverloading symbology is necessary / inevitable. And a perpetual source of problems. What can we do?
20:59RSchulzSubtex?
20:59RSchulzSubtext
20:59RSchulzAs in http://www.subtextual.org/
20:59Chousukehumans are pretty good at handling overloaded meanings though.
21:00RSchulzExcept when they're not...
21:00Chousukeor rather, 1 symbol -> n meanings
21:00RSchulzBut then, what would life be without puns and double-entendres?
21:01ChousukeMost like the majority of words you use have at least two meanings
21:01Chouserwell, I've got a an applet loading, but I can't get it to draw anything.
21:01Chousukemost likely*
21:01RSchulzOK, rhickey: Now lets talk about no dotted lists...
21:01rhickeyRSchulz: I'm not talking about dots anymore tonight
21:01RSchulzJust kidding, of course.
21:02RSchulzDid you consider talking to SVJUG when you're out here for Java-One? I'm sure they'd welcome you.
21:03rhickeyI'm putting together my proposals this weekend, will propose for Conference One as well, a free conference on the preceding day
21:03RSchulzFree? What? Where? When?
21:03rhickeySame venue I think, day before Java One, SF
21:04RSchulzBut free you say?
21:04RSchulz(I have _very_ limited resources.)
21:06Chousukegah
21:07Chousukewhy is sourceforge not letting me clone clojure-contrib
21:07rhickeyhttp://developers.sun.com/events/communityone/
21:07Chousukemaybe it thinks all the checkouts are a DoS attempt :P
21:08RSchulz$200 doesn't equate to free for me...
21:26mfredricksonshow of hands: academics using clojure?
21:27mfredrickson(I thinking of putting together a conference -- or tagging along on something)
21:35rhickeyuser=> (macroexpand '(.getMethods String))
21:35rhickey(. (clojure.core/identity String) getMethods)
21:41Chouserhm!
21:42mmcgrananice
21:43clojurebotsvn rev 1158; force instance member interpretation of (.method ClassName), e.g. (.getMethods String) works
21:44danlarkinno more FAQ #1?!
21:45rhickeydanlarkin: maybe:
21:45rhickeyuser=> (. String getMethods)
21:45rhickeyjava.lang.NoSuchFieldException: getMethods (NO_SOURCE_FILE:8)
21:45Chouserwon't be #1 anymore though
21:46rhickeybut if people use the preferred .member for instance and class/member for static there should be no confusion
22:04Chouserclojurebot: show is clojure.contrib.repl-utils/show
22:04clojurebotOk.
22:12Chouserand that's got a 'source' that works better.
22:14danlarkinChouser: woo hoo
22:15mmcgranaChouser: very nice, thanks
22:17hiredmanone of these days I'll have to grab contrib
22:18Chouserhiredman: or you can just write all that code again yourself.
22:18danlarkinhiredman: I use it all the time for checking on usage
22:18hiredmanI have show.clj
22:18hiredmanfrom the ml
22:19danlarkinconspire takes an ISeq
22:20danlarkinWOW what a good joke
22:21Chouserheh
22:42gp can I use gnuplot with clojure?
22:42gpmatlab?
22:45hiredmanI am sure there must be java bindings for both of those
23:18gpwhat is the dfference between #^{:doc... and (defn f "doccing" ?
23:20Chouserno diff
23:20gpand can :test be used for automatic unit-testing?
23:21gphow do I call that?
23:21Chouser(doc test)
23:21clojurebottest [v] finds fn at key :test in var metadata and calls it, presuming failure will throw exception; arglists ([v])
23:49gpthe test example on special forms doesnt seem to be working
23:49gpi get :no-test
23:49gpwhen doing (test mymax)
23:51Chouser(test #'mymax)