Hi Andrea,

You need to make two little changes: (1) satisfies? is a predicate about instances, not types, and (2) the extend predicates check for explicit extension:

(defprotocol P
(foo [x]))

(deftype T [])

(extend ::T
  P
  {:foo (fn [] "dummy")})

(extends? P T)
=> true

(satisfies? P (T))
=> true

(extenders P)
=> (:user/T #<user$T__2988 user$t__2...@57070723>)

Hi everyone,

if I run this code:

(defprotocol P
(foo [x]))

(deftype T []
 P
 (foo [] "dummy"))

(extends? P T)
;==> nil
(satisfies? P T)
;==> nil
(extenders P)
;==>nil

are they not yet implemented?

anyway when I run

(type P)
;==> clojure.lang.PersistentArrayMap

So the protocol is simply a map.

I thought that P had some kind of protocol type, that extends
something like:

(defprotocol ProtocolProtocol
(extends? [p t])
(extenders [p])
(satisfies? [p t]))


(deftype Protocol [methods implementers]
ProtocolProtocol
(extends? [t] ...)
(extenders [] ...)
(satisfies? [t] ...))

Does it make any sense?

--
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

--
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