On Mar 24, 2009, at 11:19, mikel wrote:

> Dispatch is wholly deterministic; you never need prefer-method. There

Then what is the rule for choosing one method when there are several  
that match the arguments?

> In the scope in which a generic function is applied, next-method is
> always bound to the next applicable method in a total ordering of
> applicable methods for the arguments supplied (see the first
> java.lang.Integer method below for an example of how to use next-
> method). applicable-methods is always bound to a function that returns
> a list of applicable methods, ordered from most- to least-specific;
> next-method is equal to (first (applicable-methods)).

So I guess that the chosen method is the first one in the applicable- 
methods list, meaning the "most specific" one. The question is then  
how "specificity" is defined, in particular for multiple argument  
dispatch. Suppose in your example that I provide

        (define-method add [x y] ...)
        (define-method add [[x java.lang.Integer] y] ...)
        (define-method add [x [y java.lang.Integer]] ...)

and call (add 3 3). Which of the methods is chosen?

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