From: Marco Antoniotti
Subject: Arguments to :writer function in slot definitions.
Date: 
Message-ID: <lwu2u2umzm.fsf@copernico.parades.rm.cnr.it>
Hello,

this is one thing it has been nagging me for quite some time now.

The Hyperspec does not help.

It seems like that when defining (at least in CMUCL)

(defclass zz ()
  ((slot :writer set-slot))    ; Write-only memory!!!! :)
  )

the signature of the writer gf method is

  (defmethod set-slot (value (z zz)) #|do the (setf (slot-value ..)) |#)

which results into calls of the form

  (set-slot the-value the-zz)

Now, I could not really find in the Hyperspec the definition of the
arg list for the writer gf.  But I am curious to know what is the
rationale for this choice, beyond the fact that you can write things
like

  ((slot :writer (setf slot)))

..and that some of the SETF-related functions seem to like the "value"
argument in the first position of the arglist.

Just curious.

Cheers

-- 
Marco Antoniotti ===========================================
PARADES, Via San Pantaleo 66, I-00186 Rome, ITALY
tel. +39 - 06 68 10 03 17, fax. +39 - 06 68 80 79 26
http://www.parades.rm.cnr.it/~marcoxa
From: Kent M Pitman
Subject: Re: Arguments to :writer function in slot definitions.
Date: 
Message-ID: <sfw3e1maxxk.fsf@world.std.com>
Marco Antoniotti <·······@copernico.parades.rm.cnr.it> writes:

>   (set-slot the-value the-zz)
> 
> Now, I could not really find in the Hyperspec the definition of the
> arg list for the writer gf.  But I am curious to know what is the
> rationale for this choice, beyond the fact that you can write things
> like
> 
>   ((slot :writer (setf slot)))
> 
> ..and that some of the SETF-related functions seem to like the "value"
> argument in the first position of the arglist.

The reason that SETF takes new-value first is because you can't add an
argument at the end after options and rest.  That is, for a function
with arglist (x &rest y), the setter can't be (x &rest y new-value)
so the head of the list is the only place you can put it where you can
mechanically create a new and coherent and predictable arglist.

Why the writer takes its arguments in that order is a mystery to me
these days though something tells me there was a reason.
My recollection was that New Flavors did it the other way.
(New Flavors is distinguished from Old Flavors by the replacement of
SEND with generic functions, among other things, so it had a similar
set of issues.)  So whatever we did was, I'm pretty sure, going against
the grain of current practice, and I *suspect* the issue was that
people had an awful time remembering if new-value came first or last,
and that we just wanted a single language-wide rule so that people
didn't misremember.  Remember that if you have
 (SET-FRIEND fred sally)
you might have a problem that you can't detect the args are in the 
wrong order, so it's very hard to signal a compiler diagnostic if the
user has gotten confused.  Painful as it may be to remember that new-value
goes first, at least you don't have to remember that it sometimes goes
first and have to learn where it does and where it doesn't.

So I doubt it's the :writer (setf slot) thing you're saying, although
that's a direct consequence of this other issue. 

But I'm mostly just guessing on this, based on other facts I remember
more clearly and based on the general kinds of reasoning we typically
did.  My specific memory on this is not very good, so please attach to
any of the above with appropriately weak pointers.