I'll be more specific :)

"If you are used to Java style type inheritance you might be surprised that 
there is no explicit record/protocol mechanism for defining one type as a 
“sub-type” of another and inheriting the super-type’s implementation. You might 
even think that Clojure datatypes are less powerful than Java clasess… but you 
would be wrong."

So to summarize, there's no protocols/defrecord inheritance. The article 
provides an example
how to you can override implementations of an existing protocol (extend 
TrainedDog (merge base-behavior ...)
from another protocol to change them. It's not inheritance, it's overriding 
implementations.

Luc P.

On Sun, 28 Aug 2011 14:42:46 -0400
Alexandre Patry <patry...@iro.umontreal.ca> wrote:

> 
> On 2011-08-28, at 2:27 PM, Luc Prefontaine wrote:
> 
> > On Sun, 28 Aug 2011 14:19:46 -0400
> > Alexandre Patry <patry...@iro.umontreal.ca> wrote:
> > Some reading:
> > 
> > http://david-mcneil.com/post/1475458103/implementation-inheritance-in-clojure
> 
> Thanks for the quick answer.
> 
> From what I understand, this article talks about inheritance of
> implementation. I would like inheritance of "specification", like :
> 
> (defprotocol State
>   (precede? [this other-state])
>   (completed? [this]))
> 
> 
> (defprotocol Hypothesis
>   ;; Here, I would like to specify that an hypothesis must implement
> the State protocol
> 
>   ;; but also the value and successors functions
>   (successors [this])
>   (value [this]))
> 
> It would be simple interface inheritance in java, but I do not know
> how to express it in clojure.
> 
> 
> > 
> > Luc P.
> > 
> >> Hi,
> >> 
> >> I would like to define a protocol as a super set of another. For
> >> example:
> >> 
> >> (defprotocol P1
> >>  (f [this]))
> >> 
> >> (defprotocol P1WithExtras
> >>  ;; something like :extends P1
> >>  (g [this]))
> >> 
> >> ;; P1WithExtras should now contain f and g.
> >> 
> >> I may have missed, but I did not find how to do it from the
> >> documentation.
> >> 
> >> Any suggestions on how to define a protocol as a superset of
> >> another? Or on an alternative solution?
> >> 
> >> Thanks,
> >> 
> >> Alexandre
> >> 
> > 
> > 
> > 
> > -- 
> > Luc P.
> > 
> > ================
> > The rabid Muppet
> > 
> > -- 
> > 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
> 



-- 
Luc P.

================
The rabid Muppet

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