2010/2/11 Bryce <fiat.mo...@gmail.com>:
> I'm wondering what the rationale is for using multimethods vs. cond,
> and where it's best to use either?  Multimethods seem to be very
> seldom used, usually to dispatch on type, but I can see advantages to
> using data to dynamically define only the methods you need, rather
> than having all-encompassing cond statements.  It also seems like
> generally cleaner code.  Is there a speed benefit to one or the other?

There is clearly a speed benefit of just using cond, and sometimes it
can be the reason for the choice.

multimethods help you implement the Open / Close principle : they are
open to users providing more specific implementations for more
specific dispatch values. And for this it is not necessary for the
user of the multimethod to change existing implementations for certain
dispatch values (the close part).

There's certainly much to say about the differences, but here's my contribution.

HTH,

-- 
Laurent

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