On 14 Dec, 2010, at 19:47 , Stuart Sierra wrote:

> On Dec 14, 2:31 am, Konrad Hinsen <konrad.hin...@fastmail.net> wrote:
>> That's actually what clojure.contrib.complex-numbers already uses! And  
>> it's based on multimethods, not protocols, because of all those binary  
>> operations.
> 
> It is possible, though not trivial, to do 2-argument dispatch with
> protocols.  See http://paste.lisp.org/+2023 for an example.  I have no
> idea how well this performs compared to multimethods.

Interesting idea, a double dispatch hidden behind a couple of macros. It would 
be interesting indeed to compare its efficiency to a multimethod-based 
solution. The latter retains one advantage though: it is possible to dispatch 
arbitrary n-ary functions. In particular, it is possible to have unary and 
binary versions of +, - etc. But I suppose your protocol-based solution can be 
extended in that way as well.

Konrad.

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