I would suggest adding something on the lines of these - it is
confusing to newcomers, and it really isnt complete documentation to
not include. The crux of the matter is how clojure defines methods
when a record has inline protocols, etc. Maybe i missed this in the
documentations.


1. extend-protocol will allow the record to refer to the same protocol
if the protocol is redefined (and even if the protocol is simply
reloaded, but the definition doesnt change, it will still screw up
records whicih define the protocol inline), inline wont

http://groups.google.com/group/clojure/browse_thread/thread/607902114ab55ecd

2. record definitions with inline protocol definitions get redifined
on a :reload-all (i think), even if their definitions dont actually
change. This means previous records of the same type dont refer to the
new same type - this is only of a concern when developing at the repl.
This is a problem for type hinting and dispatching on classes in
multimethods, and for testing types.


3. if defrecord has inline protocol definitions, you can access these
methods with the dot syntax - otherwise you cant.
;;example - dot
(defprotocol PSocket (close [this]))
(defrecord socket []
  PSocket
  (close [this] true))
(.close (socket.)) and (close socket) works
(defrecord socket2 [])
(extend-protocol PSocket
  socket2
  (close [this] false))

(.close (socket2.)) ;;no matching field found error
(close (socket2.)) ;;=> returns false

And for defprotocol

1. (defprotocol Test)
Test => returns a map

while in another ns, when you import the ns which has Test, Test will
return the actual class.
This is a problem for multimethods in the same ns - of course, you can
just do myns.Test

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

Reply via email to