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

DEFMETHOD automagic references considered random

re: Can someone please explain to me the reason why specialized arguments are
    automagically referenced in the bodies of methods?  

Part of the purpose of the specialized variables is to do method
selection "within the generic function itself";  so there is a sense
in which the formal parameter variable is being indirectly referenced.
For example, in the following generic function WHAT-COUNT, no method at 
all explicitly references the variable "x"; 

    (defmethod what-count ((x foo)) 1)
    (defmethod what-count ((x bar)) 2)
    (defmethod what-count ((x baz)) 3)

but the discrimination must have referenced it implicitly, just as surely 
as if it had been written as a non-generic function as follows:

    (defun what-count (x)
      (etypecase x 
	(foo 1)
	(bar 2)
	(baz 3)))

-- JonL --