I'm returning to Clojure in earnest for the first time since 1.1 (and
very happy to be back!). Apologies if this question revisits old
issues.

I'm trying to understand why the semantics of protocols are such that
the third statement here returns true:

user=> (defprotocol Bashable (bash [this]) (boom [this]))
Bashable

user=> (defrecord Record [] Bashable (bash [this] "bash!"))
user.Record

user=> (and (satisfies? Bashable (Record.)) (extends? Bashable
Record))
true

This returns true even though boom is not implemented for Record:

user=> (boom (Record.))
AbstractMethodError user.Record.boom()Ljava/lang/Object;  user/eval55
(NO_SOURCE_FILE:3)

Apparently, types/records can implement a protocol "in name only."
What is behind this choice? Intuitively, I would have conceived of a
protocol as a collection of methods all of which must be implemented
in order for a type/record to extend the protocol.

A second question. How does one "explicitly" extend a protocol per the
documentation of  the extenders function? Intuitively, I would have
thought that the code above "explicitly" extends Bashable if it
extends Bashable at all. Yet:

user=> (extenders Bashable)
nil

Thank you.

All the best, Garth Sheldon-Coulson

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