#clojure log - May 19 2008

The Joy of Clojure
Main Clojure site
Google Group
List of all logged dates

10:12 ozzilee: Is there a way to get a java.util.HashMap from a clojure.lang.PersistentHashMap ?

10:17 Alternately, has someone already created a json encoder for Clojure?

10:20 rhickey: Clojure maps do not yet implement java.util.Map, so you'd have to reduce:

10:20 (reduce (fn [hm [k v]] (.put hm k v) hm) (HashMap. (count m)) m)

10:20 json encoder should be trivial

10:22 ozzilee: That'll work.

10:22 Works with the json lib from couchdb4j anyway.

10:40 rhickey: Calling (next) when at the end of a zipper seems to block forever. Bug?

10:40 rhickey: code?

10:41 lisppaste8: ozzilee pasted "next blocks forever" at http://paste.lisp.org/display/60978

10:48 ozzilee annotated #60978 with "end? doesn't work" at http://paste.lisp.org/display/60978#1

11:14 wabash: rhickey: 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:19 rhickey: TCO 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:20 dudleyf: It 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:21 But nobody's pushing very hard for TCO right now

11:21 rhickey: I don't think TCO is a priority for them, as it's not a hot feature for JRuby or Groovy

11:22 dudleyf: rhickey: You could start pushing for it in the jvm-languages group

11:22 rhickey: Their focus is on "arguably popular" languages, so JRuby/Jython/Groovy

11:22 dudleyf: The JRuby and Groovy guys are just the most vocal

11:23 rhickey: I don't think it's that simple

11:24 dudleyf: Well, it's never that simple ;-)

11:24 rhickey: TCO is a pretty big change, JVM-wise

11:24 wabash: rhickey: dudleyf: thank you.

11:25 rhickey: SISC?

11:25 dudleyf: Bigger than continuations?

11:25 rhickey: but tail calls for loops will never be idiomatic JRuby/Jython/Groovy/Java

11:25 wabash: http://www.google.com/search?q=sisc%20scheme&sourceid=mozilla2&ie=utf-8&oe=utf-8

11:26 dudleyf: I don't know - I don't think they should add continuations in any case

11:26 dudleyf: Really?

11:26 Security concerns?

11:29 rhickey: I think continuations might be neat in theory, but not in practice

11:35 Chouser: 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:04 ozzilee: fixed - thanks for the report

12:05 ozzilee: np, thanks for the fix

12:23 nsinghal: e

12:34 Chouser: rhickey: I'll look at it after lunch -- thanks for fixing it anyway. ;-)

13:24 rhickey: 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:56 ozzilee: Is it correct that keywords starting with a number are not allowed?

15:57 rhickey: yes, not allowed

15:58 ozzilee: Ok. Just saw the rules for symbols. Thanks.

16:16 Is 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:17 rhickey: no

16:17 ozzilee: Ok. I guess I can use with-local-vars to set a flag?

16:19 * ozzilee is not sure what that sentence should have a question mark.

16:28 drewr: How 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:28 http://lnk.nu/patricklogan.blogspot.com/kpy.html

16:29 Haha, didn't get to the comments yet where rhickey already responded. :-)

16:29 lisppaste8: ozzilee pasted "illegal exception table range" at http://paste.lisp.org/display/60996

16:29 ozzilee: Not sure if the problem lies with me or Clojure, don't know what "illegal exception table range" means.

16:29 rhickey: drewr: my comment was submitted this morning - just got posted

16:37 ozzilee: rhickey: Can you give me any hints as to what's going wrong with the above paste?

17:18 lisppaste8: ozzilee annotated #60996 with "less noise" at http://paste.lisp.org/display/60996#1

17:45 ozzilee annotated #60996 with "nested try is borked" at http://paste.lisp.org/display/60996#2

17:46 rhickey: please be patient, I'm looking into it

17:47 ozzilee: rhickey: That's all you had to say :-)

17:47 Just playing with it myself, not trying to needle you.

17:47 rhickey: it has to do with no-effect statements like 1 and nil

17:48 ozzilee: Huh, you're right.

17:48 rhickey: (try (try 1 (catch Exception e 2)) 3) has the problem but (try (try (prn 1) (catch Exception e 2)) 3) doesn't

17:50 ozzilee: Interesting.

17:51 rhickey: nil and 1 in non-tail positions don't make much sense

17:52 ozzilee: Not particularly, unless you're checking to see if an assert-exception macro works for non-exception-throwing-code :-)

17:53 I just stuck a (print) in there for now.

22:34 rhickey_: ozzilee: (try (try 1 ... is fixed

23:37 jonathan___: 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)

Logging service provided by n01se.net