#clojure logs

2008-05-19

10:12ozzileeIs there a way to get a java.util.HashMap from a clojure.lang.PersistentHashMap ?
10:17ozzileeAlternately, has someone already created a json encoder for Clojure?
10:20rhickeyClojure maps do not yet implement java.util.Map, so you'd have to reduce:
10:20rhickey(reduce (fn [hm [k v]] (.put hm k v) hm) (HashMap. (count m)) m)
10:20rhickeyjson encoder should be trivial
10:22ozzileeThat'll work.
10:22ozzileeWorks with the json lib from couchdb4j anyway.
10:40ozzileerhickey: Calling (next) when at the end of a zipper seems to block forever. Bug?
10:40rhickeycode?
10:41lisppaste8ozzilee pasted "next blocks forever" at http://paste.lisp.org/display/60978
10:48lisppaste8ozzilee annotated #60978 with "end? doesn't work" at http://paste.lisp.org/display/60978#1
11:14wabashrhickey: Thanks for answering my questions last time. I was leading up to a question: Is it fundamentally impossible to do TCO on JVM due to current JVM lack of primitives to do so? Would TCO ever be possible on the JVM without a new JVM design?
11:19rhickeyTCO is easy if you are an interpreter - see SISC Scheme. Using Java's call stack, the JVM would have to provide it. There are no fundamental technical difficulties, but potential issues for the security model, which uses the call stack to ensure privileges.
11:20dudleyfIt won't need an entirely new JVM design, there are people at Sun working on modifications of the JVM to support languages other than Java
11:21dudleyfBut nobody's pushing very hard for TCO right now
11:21rhickeyI don't think TCO is a priority for them, as it's not a hot feature for JRuby or Groovy
11:22dudleyfrhickey: You could start pushing for it in the jvm-languages group
11:22rhickeyTheir focus is on "arguably popular" languages, so JRuby/Jython/Groovy
11:22dudleyfThe JRuby and Groovy guys are just the most vocal
11:23rhickeyI don't think it's that simple
11:24dudleyfWell, it's never that simple ;-)
11:24rhickeyTCO is a pretty big change, JVM-wise
11:24wabashrhickey: dudleyf: thank you.
11:25wabashrhickey: SISC?
11:25dudleyfBigger than continuations?
11:25rhickeybut tail calls for loops will never be idiomatic JRuby/Jython/Groovy/Java
11:25rhickeywabash: http://www.google.com/search?q=sisc%20scheme&sourceid=mozilla2&ie=utf-8&oe=utf-8
11:26rhickeydudleyf: I don't know - I don't think they should add continuations in any case
11:26dudleyfReally?
11:26dudleyfSecurity concerns?
11:29rhickeyI think continuations might be neat in theory, but not in practice
11:35rhickeyChouser: ozzilee's bug is due to the change in destructuring. Do you recall why, if given a nil as a map destructuring source, you changed it to a {} ? Some code in zip relies on :as binding of nil map to be nil, i.e. :as == what was supplied.
12:04rhickeyozzilee: fixed - thanks for the report
12:05ozzileenp, thanks for the fix
12:23nsinghale
12:34Chouserrhickey: I'll look at it after lunch -- thanks for fixing it anyway. ;-)
13:24Chouserrhickey: yeah, you caught it. I used the map as a function instead of calling "get" so that sets would work, but then a nil input broke it.
15:56ozzileeIs it correct that keywords starting with a number are not allowed?
15:57rhickeyyes, not allowed
15:58ozzileeOk. Just saw the rules for symbols. Thanks.
16:16ozzileeIs there any way to break out of a function early? I'm trying to write a assert-exception macro, and I want to return in the (catch) block.
16:17rhickeyno
16:17ozzileeOk. I guess I can use with-local-vars to set a flag?
16:28drewrHow true is this? "Beware of languages like Scala and Clojure that intend to be safer concurrently than Java - they still run on the JVM and integration with Java code. So by definition their safety only can go so far."
16:28drewrhttp://lnk.nu/patricklogan.blogspot.com/kpy.html
16:29drewrHaha, didn't get to the comments yet where rhickey already responded. :-)
16:29lisppaste8ozzilee pasted "illegal exception table range" at http://paste.lisp.org/display/60996
16:29ozzileeNot sure if the problem lies with me or Clojure, don't know what "illegal exception table range" means.
16:29rhickeydrewr: my comment was submitted this morning - just got posted
16:37ozzileerhickey: Can you give me any hints as to what's going wrong with the above paste?
17:18lisppaste8ozzilee annotated #60996 with "less noise" at http://paste.lisp.org/display/60996#1
17:45lisppaste8ozzilee annotated #60996 with "nested try is borked" at http://paste.lisp.org/display/60996#2
17:46rhickeyplease be patient, I'm looking into it
17:47ozzileerhickey: That's all you had to say :-)
17:47ozzileeJust playing with it myself, not trying to needle you.
17:47rhickeyit has to do with no-effect statements like 1 and nil
17:48ozzileeHuh, you're right.
17:48rhickey(try (try 1 (catch Exception e 2)) 3) has the problem but (try (try (prn 1) (catch Exception e 2)) 3) doesn't
17:50ozzileeInteresting.
17:51rhickeynil and 1 in non-tail positions don't make much sense
17:52ozzileeNot particularly, unless you're checking to see if an assert-exception macro works for non-exception-throwing-code :-)
17:53ozzileeI just stuck a (print) in there for now.
22:34rhickey_ozzilee: (try (try 1 ... is fixed
23:37jonathan___There's a really nice continuations example in the Expert F# book where it's, errr, used in a tree traversal I think (bit over my head, but at least it's not monads)