On Wed, Mar 25, 2009 at 1:44 AM, Konrad Hinsen
<konrad.hin...@laposte.net> wrote:
> Could you elaborate a bit on this? I haven't met any major obstacles
> with multimethods yet. The dispatch functions give quite a lot of
> flexibility in practice. In what situation did you find them
> inconvenient?

To summarize, I think the points that have been raised here and on
related threads are that:
1. Structs don't inherently have a type.  If you want to dispatch on
type (a common use-case), you have to make a constructor that inserts
the type information as part of the struct.  Some have expressed
concern that it may be too easy for this "type information" to be
altered, or worse, the data could be "changed" or "removed" in a way
that makes the struct inconsistent with the type label it carries
around.
2. No way to call "next-method" or "super", which limits the ability
to reuse related methods.
3. The dispatch mechanism requires a lot of explicit prefer-methods,
or else it may be hard to guarantee you won't get a run-time error
from a situation the dispatch system considers ambiguous.  This also
makes code less extensible because to add a method, you must know
about all the other methods that have been implemented in order to
insert all the appropriate preferences.

Honestly, the one time I used Clojure's multimethods (contrib.math),
they suited my needs perfectly, but I definitely see where these
concerns are coming from.  The existing mechanism is very flexible in
one respect: you can dispatch on anything you want, not just type.  In
other respects, it seems like Clojure's multimethods are less
sophisticated than their CLOS/Dylan counterparts.  If there is a way
to achieve the same things in Clojure, it's not readily apparent (see
recent thread about the next-method/super issue, for example).

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