#clojure log - Jul 19 2008

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

12:20 kotarak: Hi. I have trouble with my lazy-map. When a simply evaluate it at the Repl, Clojure complains "java.lang.ClassCastException: clojure.lang.LazilyPersistentVector", but when I add IPersistentVector to the proxy (already has IPersistentMap and IFn) I get "java.lang.ClassFormatError: Repetitive method name/signature in class file clojure/lang/Proxy__3258" Any hints?

12:20 * kotarak has no clue about Java.

12:30 Chouser: I'm guessing IPersistentVector and IPersistentMap have some method signatures in common?

12:31 kotarak: Maybe. Something like Associative and IPersistentCollection and the like.

12:31 Chouser: Maybe Java doesn't know which one to call? Or maybe Clojure's proxy function isn't built to handle it yet.

12:32 kotarak: geez.... Now I have a lazy map, which works. But blows at the Repl....

12:32 Chouser: It works in test code except at the Repl?

12:33 kotarak: Yes. When the map is printed the { shows up and the ClassCastException blows up.

12:33 But (m :foo) works. As well as (:foo m) :)

12:33 Chouser: ah. hm..

12:34 you get a stack trace, right?

12:34 kotarak: A short one. Yes.

12:34 java.lang.ClassCastException: clojure.lang.LazilyPersistentVector

12:34 java.lang.ClassCastException: clojure.lang.LazilyPersistentVector

12:34 at clojure.lang.RT.print(RT.java:1139)

12:34 at clojure.lang.Repl.main(Repl.java:76)

12:35 I thought, the "normal" map implements this somehow.

12:36 Chouser: RT.print has a big if/else chain to print data structures the right way

12:36 kotarak: Ok. Let me see...

12:37 Chouser: you're exception is when printing as an IPersistentMap (which sounds like the right place to be) when it calls first()

12:38 Does your proxy provide a first method?

12:38 kotarak: A second. It provides a seq.

12:39 Ok.

12:39 It's the MapEntry I think

12:39 Maybe.

12:39 Let me check.

12:39 Chouser: Dunno if this might help at all: http://n01se.net/paste/HTx

12:40 That's probably a little out of date now

12:40 oh, you're right -- RT.print is calling first() on the seq(), not on your class directly.

12:41 kotarak: Yep. I think that proxy does implement that. Just looking... (Thanks for the Class chart. Very nice. o.O)

12:45 Hmm... Is [a b] a IMapEntry?

12:45 Chouser: eh.. I don't think so. But IMapEntrys print that way, and you can use a vector where things expent an IMapEntry.

12:45 I think.

12:46 kotarak: Ok. Fixed. I looked at (seq {:foo :bar}) and saw the [ ]. So I returned a vector. Now I return the IMapEntry Proxy et voil�. It works

12:47 Chouser: great!

12:47 kotarak: thanks for the help, Chouser

12:47 Chouser: np

12:48 kotarak: haha :) It makes progress. (m :foo) - done, (:foo m) - done, (get m :foo) - done, m - done, (keys m) - wip :)))))

12:49 Chouser: :-)

12:52 kotarak: So. keys works also, but kills the lazyness. But for now I'm happy. This problem I'll tackle later on.

12:54 * Chouser nods

12:55 Chouser: bah. I screwed up my git repo of the clojure svn.

12:56 * Chouser goes out to mow the yard.

Logging service provided by n01se.net