[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: MAKE-METHOD-FUNCTION and APPLY-METHOD
- To: common-lisp-object-system@SAIL.STANFORD.EDU
- Subject: Re: MAKE-METHOD-FUNCTION and APPLY-METHOD
- From: David A. Moon <Moon@STONY-BROOK.SCRC.Symbolics.COM>
- Date: Thu, 14 Apr 88 15:01 EDT
- In-reply-to: <8804140006.AA21809@suntana.sun.com>
Comments on the rest of your message later, but two comments now:
Date: Wed, 13 Apr 88 17:06:22 -0700
From: kempf@Sun.COM
3) The creation of the dispatcher function is parameterized by both
the generic function and the method combination. There is really no
choice here, because the algorithm for calculating the effective
method depends on both the list of applicable methods (which the
generic function provides) and the method combination type.
The method combination can be obtained from the generic function by
calling generic-function-method-combination, so the only reason to
pass it as an argument to compute-discriminator-code is if it's needed
for method selection.
I think some of the problems in the discussion about bottoming out
of metacircularity come from the fact that we made method combination
metacircular without taking into account that calculating the
effective method, which is parameterized by method combination,
is a fundamental part of generic dispatch, and therefore
we introduced an infinite loop. This proposal unrolls the loop.
I see. Here's another way to write it that might make what you're doing
easier to understand:
(defmethod compute-discriminator-code
((generic-function standard-generic-function))
(let ((f (get-handler-for #'compute-effective-method
generic-function
(generic-function-method-combination
generic-function)
nil)))
#'(lambda (&rest args)
(let* ((applicable-methods
(compute-applicable-methods generic-function args))
(effective-method-form
(funcall f generic-function
(generic-function-method-combination
generic-function)
applicable-methods)) ....
get-handler-for is a new primitive that provides a proper separation
between the act of finding the effective method function and the act of
applying it. This pulls the generic dispatch for
compute-effective-method out of the loop. This is mere code hoisting,
except that it shows where to put the special case to break the
circularity.
Reactions?