David Powell <d...@djpowell.net> writes:

Hi David,

> When you create a protocol, as an implementation detail, it also
> creates a Java interface.

Is a protocal neccessarily an implementation detail?  I mean, it might
be, but it can also be a public specification of the requirements types
have to satisfy in order to integrate with my lib.

> When you list protocols in a deftype or defrecord form, the generated
> class actually implements that Java interface.  And protocol calls to
> that type call through the interface. This gives the best performance.
>
> If you add protocols to an existing class, record or type; this
> dispatch is done dynamically and interfaces aren't involved.

That suggests that `extenders' is actually a private function for doing
the dynamic dispatch.  But it's not used at all in clojure.core.  And
it's inconsistent with extends?.

user> (defrecord R2 [] Bashable (boom [this] :boom))
user.R2
user> (extenders Bashable)    ;; just returns the "dynamic" extenders
(user.Record)
user> (extends? Bashable R2)  ;; does an implements? check as well
true

IMHO, `extenders' should return also types implementing the protocol
interface directly, so that

  (extends? P T) <=> (some #(= % T) (extenders P))

holds.

Bye,
Tassilo

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