#clojure logs

2008-07-19

12:20kotarakHi. 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:30ChouserI'm guessing IPersistentVector and IPersistentMap have some method signatures in common?
12:31kotarakMaybe. Something like Associative and IPersistentCollection and the like.
12:31ChouserMaybe Java doesn't know which one to call? Or maybe Clojure's proxy function isn't built to handle it yet.
12:32kotarakgeez.... Now I have a lazy map, which works. But blows at the Repl....
12:32ChouserIt works in test code except at the Repl?
12:33kotarakYes. When the map is printed the { shows up and the ClassCastException blows up.
12:33kotarakBut (m :foo) works. As well as (:foo m) :)
12:33Chouserah. hm..
12:34Chouseryou get a stack trace, right?
12:34kotarakA short one. Yes.
12:34kotarakjava.lang.ClassCastException: clojure.lang.LazilyPersistentVector
12:34kotarakjava.lang.ClassCastException: clojure.lang.LazilyPersistentVector
12:34kotarak at clojure.lang.RT.print(RT.java:1139)
12:34kotarak at clojure.lang.Repl.main(Repl.java:76)
12:35kotarakI thought, the "normal" map implements this somehow.
12:36ChouserRT.print has a big if/else chain to print data structures the right way
12:36kotarakOk. Let me see...
12:37Chouseryou're exception is when printing as an IPersistentMap (which sounds like the right place to be) when it calls first()
12:38ChouserDoes your proxy provide a first method?
12:38kotarakA second. It provides a seq.
12:39kotarakOk.
12:39kotarakIt's the MapEntry I think
12:39kotarakMaybe.
12:39kotarakLet me check.
12:39ChouserDunno if this might help at all: http://n01se.net/paste/HTx
12:40ChouserThat's probably a little out of date now
12:40Chouseroh, you're right -- RT.print is calling first() on the seq(), not on your class directly.
12:41kotarakYep. I think that proxy does implement that. Just looking... (Thanks for the Class chart. Very nice. o.O)
12:45kotarakHmm... Is [a b] a IMapEntry?
12:45Chousereh.. I don't think so. But IMapEntrys print that way, and you can use a vector where things expent an IMapEntry.
12:45ChouserI think.
12:46kotarakOk. 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:47Chousergreat!
12:47kotarakthanks for the help, Chouser
12:47Chousernp
12:48kotarakhaha :) It makes progress. (m :foo) - done, (:foo m) - done, (get m :foo) - done, m - done, (keys m) - wip :)))))
12:49Chouser:-)
12:52kotarakSo. keys works also, but kills the lazyness. But for now I'm happy. This problem I'll tackle later on.
12:55Chouserbah. I screwed up my git repo of the clojure svn.