[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: method ordering

>My first question is how does PCL decide in what order the methods are
>to be invoked? Does method (test foo0 bar1) come before or after (test
>bar0 foo1)? Is it the order of creation of the methods. This was my
>best guess.

The algorithm for deciding which method is the most specific (and thus
which gets executed first after generic dispatch) is described in detail
in Chapter 1 of the CLOS spec. Baring method combination and EQL
methods, the bottom line is that the classes of the arguments are
compared with the classes of the specialized formal parameters from left to
right. A match occurs if the class of the argument is an element of the
class precedence list of the specialized formal parameter. The method
is selected if there are no more parameters to examine (i.e. a hit
occurs on each parameter). In practice, there are short cuts which speed
up dispatch, but, in principle, this is what is happening.

>And my next question is how can this be affected within the methods?

In a word, no. The only ways to affect the method execution sequence is
to either use method combination to define daemon methods or use 
call-next-method. Call-next-method only allows you to call the next
most specific method (defined, again, in Chapter 1 of the CLOS spec).