Tassilo Horn <t...@gnu.org> writes:
>> I don't think satisfies? is worth optimizing as using ton of it seems
>> antithetical to protocols. It signals to me that a caller does in fact
>> care about the implementation, whereas protocols are about not
>> caring. Like your PR, if you want to ensure a protocol's coverage, you
>> can also extend a protocol to Object and/or nil. Not sure what a valid
>> use case would be for calling satisfies? on a hot path would be.
>
> 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 did this to avoid lots of

(when (satisfies? AProc o)
   (do-method o))

and just have

(do-method o)

instead. But if I understand how protocols are implemented (which I
don't), I think this also avoids the type look up.

Phil
 

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