phillip.l...@newcastle.ac.uk (Phillip Lord) writes:

>> I use satisfies? for optional features, e.g., if some data structure
>> satisfies some protocol, then that optional feature is enabled, else
>> it's disabled.  But that's not really on a hot path so I don't care
>> much about satisfies? performance.
>
> Have you tried just implementing the protocol over Object to do
> nothing? Then putting use an alternative implementation of the
> protocol where you want.

I really use it for optional features for which no alternative
implementation exists.  Concretely, I have a library that can work with
several graph data structures in a uniform way.  Some of them have
first-class edges, others only have references.  For example, my lib has
a code generation facility where there's some code like

  (when (satisfies? IEdges type-graph)
    (generate-edge-access-fns ...))

But for other stuff I do extend protocols to Object (and nil) providing
a default implementation.

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
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to