[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

The values returned by SETF

    Date: Tue, 25 Aug 1987  10:12 EDT
    From: Ram@C.CS.CMU.EDU

	Date: Monday, 24 August 1987  14:47-EDT
	From: David A. Moon <Moon at STONY-BROOK.SCRC.Symbolics.COM>
	To:   D. Loewenstern <dml at NADC.ARPA>
	Re:   The values returned by SETF

	    Date: Mon, 24 Aug 87 14:25:04 EDT
	    From: dml@nadc.arpa (D. Loewenstern)

	    Is the value returned by SETF defined in general, for all
	    standard get/put functions?

	    Specifically, what is returned by (SETF (VALUES IGNORE X)
	    (VALUES 1 2))?

	SETF returns the values of its last subform (CLtL p.97).

    Actually, it says "the ultimate result of evaluating the setf form is
    the value of newvalue."  I would interpret your restatement to mean
    that it has to return all the values of the newvalue form.  I can't
    see how you can do this in a Common Lisp macro without using
    Multiple-Value-List.  At least in our implementation:

      (setf foo (values 1 2 3))  =>  1

    I would guess that the actual rule is that setf returns the number of
    values that the setf method was expecting (supposing that the setf
    method writer bothers to return the right value(s)).

The setf method writer has to return the right values, or he didn't write
his setf method correctly.  The question is what are the right values.
I now agree with you that it shouldn't be all the values of <newvalue>,
and that CLtL isn't trying to say that.

Here's what I would propose.  For all of the standard SETFs documented
in CLtL, which use only one value of <newvalue>, a portable program
can depend on SETF returning that one value and cannot depend on any
additional values.  Implementations that implement the extension 
(SETF (VALUES ...) ...) should return all the values that are used.
Thus the answer to the original question is that in implementations
where the form is not an error, it returns two values, 1 and 2.