[Openmcl-devel] Arglist of :accessors
Gary Byers
gb at clozure.com
Sun Jan 4 11:53:51 PST 2004
On Sun, 4 Jan 2004, Sven Van Caekenberghe wrote:
> I noticed the following difference between 0.13 and the latest 0.14:
>
> Welcome to OpenMCL Version (Beta: Darwin) 0.13.6!
> ? (defclass foo () ((bar :accessor get-bar)))
> #<STANDARD-CLASS FOO>
> ? (arglist #'get-bar)
> (#:FOO)
> :ANALYSIS
>
> Welcome to OpenMCL Version (Alpha: Darwin) 0.14-031220!
> ? (defclass foo () ((bar :accessor get-bar)))
> #<STANDARD-CLASS FOO>
> ? (arglist #'get-bar)
> (CCL::ARG-0)
> :ANALYSIS
>
> Maybe this has something to do with the newer slot access code or
> extended MOP support.
>
In the old code, (DEFCLASS FOO () ((BAR :READER GET-BAR))
macroexpanded into something like:
(progn
(ccl::%defclass ...)
(defmethod get-bar ((#:foo foo)) (slot-value foo 'bar)))
;the :writer case is analogous
The DEFMETHOD actually used some syntax to set the method-class of the
resulting method to STANDARD-READER-METHOD; it would have had a hard
time using DEFMETHOD to set the ACCESSOR-METHOD-SLOT-DEFINITION to
anything meaningful (even if SLOT-DEFINITIONS had really existed.)
In the MOP, it's ENSURE-CLASS's job to create accessors, and it -does-
have the information it needs to make an instance of the right method
class with the right ACCESSOR-METHOD-SLOT-DEFINITION. The actual
METHOD-FUNCTION's just boilerplate; it's probably possible to cons up
local symbol information for the automatically generated function, but
it makes a bit more sense to me to try to make the METHOD-LAMBDA-LIST
more informative (it's probably just something like (X) for readers
and (X Y) for writers ...) and to persuade ARGLIST that that's a
better source of arglist information for a method than the method
function is.
> Sven
>
> _______________________________________________
> Openmcl-devel mailing list
> Openmcl-devel at clozure.com
> http://clozure.com/mailman/listinfo/openmcl-devel
>
>
More information about the Openmcl-devel
mailing list