[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: CLOS With-Accessors
> Date: Wed, 8 Apr 1992 13:09-0400
> From: barmar@Think.COM (Barry Margolin)
> P.777 of CLtL2 contains the restriction "Any accessors specified by
> WITH-ACCESSORS must already have been defined before they are used";
> this line comes direct from the CLOS spec. And the ANSI draft's
> description of WITH-ACCESSORS says, "The consequences are undefined if
> any accessor-name is not the name of an accessor for the instance."
> In the case of the first quote, I'm not sure what it means by "used";
> does it mean "called" (i.e. at runtime), or does it mean "seen by the
> compiler"? I'd like to think that the former was intended, but that's
> true of *all* functions so I don't think the designers would have made a
> special point of it.
> The second quote has me even more confused. It may be intended just to
> restate the restriction in the first quote. This sense of the term
> "accessor" is never defined precisely in the standard (there's a
> definition of "accessor" that refers to generalized references -- e.g.
> CAR is this kind of accessor). Nowhere is it ever stated that :ACCESSOR
> defines this kind of accessor; it is just a shorthand for defining the
> appropriate methods yourself (it might also make use of
> implementation-specific optimizations, but those should be transparent
> unless you're timing or using the metaobject protocol).
> Finally, these restrictions appear to contradict other parts of the CLOS
> spec, which say that WITH-ACCESSORS is equivalent to a use of
> SYMBOL-MACROLET that replaces the "variable" references with calls to
> the specified accessor. Why should this SYMBOL-MACROLET expansion be
> dependent on how the accessor is defined?
Don't look at me, I never understood what this sentence is trying to say.
However, if I was forced to guess, I would guess that the sentence from
CLtL2 means that with-accessors is only a syntactic transformation: it
will generate calls to some functions but it won't define the functions
if they aren't already defined. You still have to use :accessor or
:reader or :writer in your defclass, even if you never directly write
calls to the functions defined there in your program, but only use
them indirectly via with-accessors.
I'm completely clueless about the quote from the ANSI CL draft. Do you
think it's a garbled paraphrase of the quote from CLtL2? Or did it come
from someplace else?