From: Peter Seibel
Subject: Accessors vs Functions
Date: 
Message-ID: <m3fzowpq4h.fsf@javamonkey.com>
In the language standard, what's the distinction between "Accessors"
and "Functions". There seems to be a fair bit of overlap between the
things labeled accessors and those in Figure 5.7, "Functions that setf
can be used with". Does accessor *maen* setf'able function? (I looked
up "accessor" in the glossary but that didn't answer my question or I
was too dense to get it.)

-Peter

-- 
Peter Seibel                                      ·····@javamonkey.com

  The intellectual level needed   for  system design is  in  general
  grossly  underestimated. I am  convinced  more than ever that this
  type of work is very difficult and that every effort to do it with
  other than the best people is doomed to either failure or moderate
  success at enormous expense. --Edsger Dijkstra

From: Steven M. Haflich
Subject: Re: Accessors vs Functions
Date: 
Message-ID: <3E8F99DC.3050602@alum.mit.edu>
Peter Seibel wrote:
> In the language standard, what's the distinction between "Accessors"
> and "Functions". There seems to be a fair bit of overlap between the
> things labeled accessors and those in Figure 5.7, "Functions that setf
> can be used with". Does accessor *maen* setf'able function? (I looked
> up "accessor" in the glossary but that didn't answer my question or I
> was too dense to get it.)

Peter, all three of the terms accessor, reader, and writer are defined
in the ANS glossary.  You should refer to these first.
From: Peter Seibel
Subject: Re: Accessors vs Functions
Date: 
Message-ID: <m3istsnwwj.fsf@javamonkey.com>
"Steven M. Haflich" <·················@alum.mit.edu> writes:

> Peter Seibel wrote:
> > In the language standard, what's the distinction between "Accessors"
> > and "Functions". There seems to be a fair bit of overlap between the
> > things labeled accessors and those in Figure 5.7, "Functions that setf
> > can be used with". Does accessor *maen* setf'able function? (I looked
> > up "accessor" in the glossary but that didn't answer my question or I
> > was too dense to get it.)
> 
> Peter, all three of the terms accessor, reader, and writer are defined
> in the ANS glossary.  You should refer to these first.
> 

Actually I did. I wasn't sure whether what "See reader and writer"
means. Does that mean all accessors are both readers and writers. Or
just that accessors readers and writers are related in some
unspecified way. Are there accessors that *aren't* readers or writers?
Does the glossary entry for accessor use the word "operator" rather
than "function" because not all accessor's are functions?

  accessor n. an operator that performs an access. See reader and writer.

  reader n. 1. a function that reads[1] a variable or slot.

  writer n. a function that writes[1] a variable or slot.

Probably also relevant:

  access n., v.t. 1. v.t. (a place, or array) to read[1] or write[1]
  the value of the place or an element of the array. 2. n. (of a
  place) an attempt to access[1] the value of the place.

  read v.t. 1. (a binding or slot or component) to obtain the value of
  the binding or slot.

  write v.t. 1. (a binding or slot or component) to change the value
  of the binding or slot.

-Peter


-- 
Peter Seibel                                      ·····@javamonkey.com

  The intellectual level needed   for  system design is  in  general
  grossly  underestimated. I am  convinced  more than ever that this
  type of work is very difficult and that every effort to do it with
  other than the best people is doomed to either failure or moderate
  success at enormous expense. --Edsger Dijkstra
From: JP Massar
Subject: Re: Accessors vs Functions
Date: 
Message-ID: <3e9057e6.150598007@netnews.attbi.com>
On Sun, 06 Apr 2003 03:13:01 GMT, Peter Seibel <·····@javamonkey.com>
wrote:

>"Steven M. Haflich" <·················@alum.mit.edu> writes:
>
>> Peter Seibel wrote:
>> > In the language standard, what's the distinction between "Accessors"
>> > and "Functions". There seems to be a fair bit of overlap between the
>> > things labeled accessors and those in Figure 5.7, "Functions that setf
>> > can be used with". Does accessor *maen* setf'able function? (I looked
>> > up "accessor" in the glossary but that didn't answer my question or I
>> > was too dense to get it.)
>> 
>> Peter, all three of the terms accessor, reader, and writer are defined
>> in the ANS glossary.  You should refer to these first.
>> 
>
>Actually I did. I wasn't sure whether what "See reader and writer"
>means. Does that mean all accessors are both readers and writers. Or
>just that accessors readers and writers are related in some
>unspecified way. 

I'd guess an accessor is either a reader or a writer, or both (with
SETF), at least when used in a 'formal' sense referring to classes and
defstructs.

>Are there accessors that *aren't* readers or writers?

IMHO, the terms reader and writer are most often used when referring
to class slots, since those have :reader and :writer options.  Whether
you would refer to some random function that accesses some part of
some random data structure as a 'reader' probably depends on the
terminology you are used to.

Personally I would use 'accessor' before I used 'reader'


>Does the glossary entry for accessor use the word "operator" rather
>than "function" because not all accessor's are functions?
>
 
All CLtL defined accessors are functions (prtty sure about that).
Doesn't mean you couldn't write a macro

(defmacro first-name (x) `(car ,x))

and call FIRST-NAME an accessor.   That's the terminology I would use.
From: Joerg Hoehle
Subject: Re: Accessors vs Functions
Date: 
Message-ID: <ullyjsrqr.fsf@dont.t-systems.UCE.spam.no.com>
······@alum.mit.edu (JP Massar) writes:
> Doesn't mean you couldn't write a macro
> (defmacro first-name (x) `(car ,x))
> and call FIRST-NAME an accessor.   That's the terminology I would use.

Me too.  Actually, first-name *is* an accessor, since you can read and
write using it (my take at an interpretation of a definition).
(setf (first-name a) b) works as a writer.

But that's not compatible with what Kent Pitman said elsewhere in this thread:
>If you're talking about the word that introduces a dictionary entry,
> Accessor FOO
>always introduces a function with an associated functional SETF method.

First-name is not a function. So Kent wouldn't call it an accessor,
if I understand him right.

Regards,
	Jorg Hohle
Telekom/T-Systems Technology Center
From: Kent M Pitman
Subject: Re: Accessors vs Functions
Date: 
Message-ID: <sfwadezbuvb.fsf@shell01.TheWorld.com>
Joerg Hoehle <············@dont.t-systems.UCE.spam.no.com> writes:

> ······@alum.mit.edu (JP Massar) writes:
> > Doesn't mean you couldn't write a macro
> > (defmacro first-name (x) `(car ,x))
> > and call FIRST-NAME an accessor.   That's the terminology I would use.
> 
> Me too.  Actually, first-name *is* an accessor, since you can read and
> write using it (my take at an interpretation of a definition).
> (setf (first-name a) b) works as a writer.
> 
> But that's not compatible with what Kent Pitman said elsewhere in this thread:
> >If you're talking about the word that introduces a dictionary entry,
> > Accessor FOO
> >always introduces a function with an associated functional SETF method.
> 
> First-name is not a function. So Kent wouldn't call it an accessor,
> if I understand him right.

I meant to say I would not label it 'Accessor FIRST-NAME' when writing its
dictionary entry, yes.

But I reserved the right to refer to it as an 'accessor' in the running
text because the purpose of the glossary was to document the meany meanings
that these terms customarily take on in the community.

The vague definition of 'accessor' in the ANSI CL glossary actually spans
the relevant set of things, but it would have been better for me to have
numbered definitions enumerating the various situations.
vaguely (and probably requiring wordsmithing):

 n+1. a function defined by :accessor in defclass to read the value of
      a slot, which is possible to set with an associated setter using SETF.
      ``The functions X-POS, Y-POS, and Z-POS can be defined to access
        the partial position of a user-defined PEBBLE object, since those 
        slots are expected to change, but the MASS-OF function should 
        probably be defined just to read the mass, which is not generally
        expected to change.''
 n+2. a function or macro that reads the value of a place, and that
      has a setter for that place available using SETF.
      ``Not only can CAR can be used to access the left half of a cons,
        but a user-defined macro LHS might access that place as well.''
 n+3. (archaic) a function or macro that reads the value of a place,
      even though there is no setter for that place available using SETF.
      ``CELL-ERROR-NAME can be used to access the name in an object
        of class UNBOUND-VARIABLE, but a user-defined macro synonym
        UNBOUND-VARIABLE-NAME might be defined by the user to access
        the name as well.''

The heavy use of "or" in the existing set of expanded definitions covers
all of these, but it may also reach some situations that can't even 
happen, too, so extra exposition might have clarified.

The problem with the existing glossary wording is similar to the problem
I heard in a radio commercial the other day, which said something like:

 If you or someone you know has had a cancer that led to a hysterectomy
 or death, you should contact us.
From: Kent M Pitman
Subject: Re: Accessors vs Functions
Date: 
Message-ID: <sfwwui6sege.fsf@shell01.TheWorld.com>
Peter Seibel <·····@javamonkey.com> writes:

> Actually I did. I wasn't sure whether what "See reader and writer"
> means. Does that mean all accessors are both readers and writers.

It's ever-so-slightly left for you to puzzle out.

Note that accessor entries in the dictionary have function signatures
both like
 car x => object
and
 (setf (car x) new-object)

Is there _really_ something that hard to figure out about this?
From: Kent M Pitman
Subject: Re: Accessors vs Functions
Date: 
Message-ID: <sfwr88ese7p.fsf@shell01.TheWorld.com>
Peter Seibel <·····@javamonkey.com> writes:

> Actually I did. I wasn't sure whether what "See reader and writer"
> means. Does that mean all accessors are both readers and writers. Or
> just that accessors readers and writers are related in some
> unspecified way. Are there accessors that *aren't* readers or writers?
> Does the glossary entry for accessor use the word "operator" rather
> than "function" because not all accessor's are functions?

Can you please ask these questions in context?

Universal quantification is hard in a document of this size.  There are
sure to be individual situations that are not to any particular rule.

Please cite individual uses that you find ambiguous so that we can debug
your individual reading.  

Please do NOT do the accidental or intentional equivalent of laying traps
for people by asking them for a rule and then later citing apparent
contradictions, since the real rule is not an overarching rule but rather
is a requirement that you read the whole document as fairly as you can.
From: Peter Seibel
Subject: Re: Accessors vs Functions
Date: 
Message-ID: <m3ptnycbj7.fsf@javamonkey.com>
Kent M Pitman <······@world.std.com> writes:

> Peter Seibel <·····@javamonkey.com> writes:
> 
> > Actually I did. I wasn't sure whether what "See reader and writer"
> > means. Does that mean all accessors are both readers and writers.
> > Or just that accessors readers and writers are related in some
> > unspecified way. Are there accessors that *aren't* readers or
> > writers? Does the glossary entry for accessor use the word
> > "operator" rather than "function" because not all accessor's are
> > functions?
> 
> Can you please ask these questions in context?

Okay, sorry. Here's my real problem:

As I've mentioned in other threads, I'm writing some material for
people new to lisp. I've been trying to refer to the common lisp
operators correctly as macros, functions, and special forms. This
seems useful as Section 3.1.2.1.2 Conses as Forms describes how
compound forms are evaluated when the first symbol names a special
form, a macro, a function, or a lambda form. 

It seems that if you know whether a given operator is a function,
macro, or special form *and* understand 3.1.2.1.2 you're on your way
to a fairly complete understanding of how all compound forms involving
basic common lisp operators will be evaluated.

But in order to understand how a compound form will be evaluated whose
first symbol names an "accessor" it seems I need to know whether the
accessor is really a function, a macro, or a special form. This is
obviously easier to know if accessors are *always* functions (as they
seem to be).

And since I was thinking about how to explain this stuff I discovered
my own lack of clarity about what distinction was being drawn by
labeling some functions "accessors".

That's all. I'm not trying to find contradictions or spec--I'm just
trying to clarify my reading of it.

-Peter

-- 
Peter Seibel                                      ·····@javamonkey.com

  The intellectual level needed   for  system design is  in  general
  grossly  underestimated. I am  convinced  more than ever that this
  type of work is very difficult and that every effort to do it with
  other than the best people is doomed to either failure or moderate
  success at enormous expense. --Edsger Dijkstra
From: Kent M Pitman
Subject: Re: Accessors vs Functions
Date: 
Message-ID: <sfwptnyhthj.fsf@shell01.TheWorld.com>
Peter Seibel <·····@javamonkey.com> writes:

> Kent M Pitman <······@world.std.com> writes:
> 
> > Peter Seibel <·····@javamonkey.com> writes:
> > 
> > > Actually I did. I wasn't sure whether what "See reader and writer"
> > > means. Does that mean all accessors are both readers and writers.
> > > Or just that accessors readers and writers are related in some
> > > unspecified way. Are there accessors that *aren't* readers or
> > > writers? Does the glossary entry for accessor use the word
> > > "operator" rather than "function" because not all accessor's are
> > > functions?
> > 
> > Can you please ask these questions in context?
> 
> Okay, sorry. Here's my real problem:
> 
> As I've mentioned in other threads, I'm writing some material for
> people new to lisp. I've been trying to refer to the common lisp
> operators correctly as macros, functions, and special forms. This
> seems useful as Section 3.1.2.1.2 Conses as Forms describes how
> compound forms are evaluated when the first symbol names a special
> form, a macro, a function, or a lambda form. 
> 
> It seems that if you know whether a given operator is a function,
> macro, or special form *and* understand 3.1.2.1.2 you're on your way
> to a fairly complete understanding of how all compound forms involving
> basic common lisp operators will be evaluated.
> 
> But in order to understand how a compound form will be evaluated whose
> first symbol names an "accessor" it seems I need to know whether the
> accessor is really a function, a macro, or a special form. This is
> obviously easier to know if accessors are *always* functions (as they
> seem to be).

If you're talking about the word that introduces a dictionary entry,

 Accessor FOO

always introduces a function with an associated functional SETF method.

However, this is NOT the same question as asking whether every use of
accessor in running text refers only to accessors defined as functions,
or, if defined as a function whether it has an associated SETF.

For example, I might have informally referred to CELL-ERROR-NAME as an
accessor in running text but that doesn't imply there is a SETF
because I do not guarantee to have been thus precise about my choice
of words everywhere in running text.  However, the dictionary entry
for CELL-ERROR-NAME is introduced by

 Function CELL-ERROR-NAME

because it's not defined by the spec to be SETF-able.  [Note that
implementations (but not users) are permitted to add a SETF to CL
defined names; however I don't personally advise it for many specific
cases, and this is one of them.  So when I talk about 'Function' here
I don't mean 'precluded from having a SETF'.]

> And since I was thinking about how to explain this stuff I discovered
> my own lack of clarity about what distinction was being drawn by
> labeling some functions "accessors".
> 
> That's all. I'm not trying to find contradictions or spec--I'm just
> trying to clarify my reading of it.

As you can see, you're still not being specific enough, even though you've
been somewhat more specific.
From: Peter Seibel
Subject: Re: Accessors vs Functions
Date: 
Message-ID: <m3d6jxdhf4.fsf@javamonkey.com>
Kent M Pitman <······@world.std.com> writes:

> > Kent M Pitman <······@world.std.com> writes:

> If you're talking about the word that introduces a dictionary entry,
> 
>  Accessor FOO
> 
> always introduces a function with an associated functional SETF method.

That's exactly what I was talking about. And that's what I surmised,
but I wanted to be sure. Thanks.
> 
> However, this is NOT the same question as asking whether every use of
> accessor in running text refers only to accessors defined as functions,
> or, if defined as a function whether it has an associated SETF.

Fair enough.

> As you can see, you're still not being specific enough, even though
> you've been somewhat more specific.

Well, thanks for reading my mind. ;-)

-Peter

-- 
Peter Seibel                                      ·····@javamonkey.com

  The intellectual level needed   for  system design is  in  general
  grossly  underestimated. I am  convinced  more than ever that this
  type of work is very difficult and that every effort to do it with
  other than the best people is doomed to either failure or moderate
  success at enormous expense. --Edsger Dijkstra
From: Steven M. Haflich
Subject: Re: Accessors vs Functions
Date: 
Message-ID: <3E9244F3.5020502@alum.mit.edu>
Peter Seibel wrote:

> Actually I did. I wasn't sure whether what "See reader and writer"
> means. Does that mean all accessors are both readers and writers. Or
> just that accessors readers and writers are related in some
> unspecified way. Are there accessors that *aren't* readers or writers?
> Does the glossary entry for accessor use the word "operator" rather
> than "function" because not all accessor's are functions?
> 
>   accessor n. an operator that performs an access. See reader and writer.
> 
>   reader n. 1. a function that reads[1] a variable or slot.
> 
>   writer n. a function that writes[1] a variable or slot.

Next thing to look at is the one place where these three terms are
used in typical relation to one another:  in the dictionary page
for defclass.

I would agree with Kent's implication elsewhere in this thread that
this has been left for the reader to figure out (and it would have
better been spelled out somewhere).  But once you realize that
a slot specification is the one place where :reader, ;writer, and
:accessor are all used in close relation to one another, the
general meaning is not hard to extract.