From: Guy@AVON.sltd.dialnet.symbolics.COM (Guy Footring)
Subject: Re: CLOS With-Accessors
Organization: The Ohio State University Department of Computer and Information Science
Date: Mon, 13 Apr 1992 09:52:00 GMT

    Date: Fri, 10 Apr 1992 18:50-0000
    From: moon@cambridge.apple.com (David A. Moon)

    > 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

I think that this is my main problem for my first query.  I got the feeling
that "accessor" was refering to accessors defined by DEFCLASS not (necessarily)
user supplied equivalents, but I couldn't quite find anything that clarified 
this definitively for either interpretation.

    >                                                             (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.
    ___________________________________

Now I'm back to my first question again, which I guess can be summarised as
"Is there anything special about the accessors defined by DEFCLASS?"

A related question: Are the following two DEFCLASS forms guaranteed to be 
equivalent in all conforming Lisp implementations?

(defclass A ()
  ((slot1 :accessor slot1)))

(defclass A ()
  ((slot1 :reader slot1 :writer (setf slot1))))


    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?
Newsgroups: comp.lang.clos