Article View: comp.lang.clos
Article #77Re: CLOS With-Accessors
From: David A. Moon
Date: Fri, 10 Apr 1992 18:50
Date: Fri, 10 Apr 1992 18:50
44 lines
2934 bytes
2934 bytes
> 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?
Technical Details
Message-ID:
<9204101844.AA08001@cambridge.apple.com>Path:
arc1-ca.pugleaf.net!sparky!news.UU.NET!ogicse!uwm.edu!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!cambridge.apple.com!moonShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!news.UU.NET!ogicse!uwm.edu!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!cambridge.apple.com!moon From: moon@cambridge.apple.com (David A. Moon) Newsgroups: comp.lang.clos Subject: Re: CLOS With-Accessors Message-ID: <9204101844.AA08001@cambridge.apple.com> Date: 10 Apr 92 18:50:15 GMT Article-I.D.: cambridg.9204101844.AA08001 Sender: daemon@cis.ohio-state.edu Organization: The Ohio State University Department of Computer and Information Science Lines: 44