Hi there,

I'm using Clojure 1.3.0 and am running into what seems like an edge-
case problem with extend-protocol (?)...

Given (defprotocol MyProtocol (action [x])),

(extend-protocol MyProtocol
  (Class/forName "[B") (action [x] "ByteArray")
  java.lang.Integer (action [x] "Integer"))

expands to (do (clojure.core/extend-type java.lang.Integer MyProtocol
(action [x] "Integer")) (clojure.core/extend-type (Class/forName "[B")
MyProtocol (action [x] "ByteArray")))

which works as expected. Note the acrobatics to get a byte[] class.


BUT, if I reorder the implementations,

(extend-protocol MyProtocol
  java.lang.Integer (action [x] "Integer")
  (Class/forName "[B") (action [x] "ByteArray"))

the expansion becomes (do (clojure.core/extend-type java.lang.Integer
MyProtocol (action [x] "Integer") (Class/forName "[B") (action [x]
"ByteArray"))), which is malformed.


Am I correct in assuming this isn't the desired behaviour? Thanks!

--
Peter Taoussanis

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to