[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
DEFMETHOD automagic references considered random
- To: rsl@ILA.COM
- Subject: DEFMETHOD automagic references considered random
- From: Jon L White <jonl@lucid.COM>
- Date: Mon, 10 Sep 1990 16:10:06 PDT
- Cc: CommonLoops.PARC@xerox.com
- In-reply-to: "rsl@ILA.COM's message of Mon, 10 Sep 1990 10:54:52 PDT <9009101754.AA04230@lava.Franz.COM>"
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 --