From: Paul Dietz
Subject: setf-like forms on VALUE places
Date: 
Message-ID: <3DB83850.387AE32C@motorola.com>
I have an ANSI CL question...

According to a (late) addition to the ANSI CL standard,
(VALUES <place> ... <place>) is a valid place.  The standard
defines SETF on a VALUES place as assigning the values
of a form to the subplaces.

But does the standard specify what VALUES places mean
in other *F forms, or even if this is legal to do?  For
example, what does this do:

   (let (x y z)
      (push (values 1 2 3) (values x y z))
      (values x y z))

In ACL, this returns (1) NIL NIL; in CMU CL it's
an error.

If the standard does not specify this, was it the intent
of the standards committee that it be permissible and, if
so, what did they think it meant?

	Paul

From: Barry Margolin
Subject: Re: setf-like forms on VALUE places
Date: 
Message-ID: <x4Xt9.20$D43.3932@paloalto-snr1.gtei.net>
In article <·················@motorola.com>,
Paul Dietz  <············@motorola.com> wrote:
>I have an ANSI CL question...
>
>According to a (late) addition to the ANSI CL standard,
>(VALUES <place> ... <place>) is a valid place.  The standard
>defines SETF on a VALUES place as assigning the values
>of a form to the subplaces.
>
>But does the standard specify what VALUES places mean
>in other *F forms, or even if this is legal to do?  For
>example, what does this do:
>
>   (let (x y z)
>      (push (values 1 2 3) (values x y z))
>      (values x y z))
>
>In ACL, this returns (1) NIL NIL; in CMU CL it's
>an error.
>
>If the standard does not specify this, was it the intent
>of the standards committee that it be permissible and, if
>so, what did they think it meant?

Most of these other forms are defined in terms of simpler forms, e.g.

(push x place) == (setf place (cons x place))

(with the additional requirement that the original order of evaluation be
maintained and subforms of place are only evaluated once).  I don't think
we intended that VALUES should cause these to translate into loops; so

(push (values 1 2 3) (values x y z)) ==
(setf (values x y z) (cons (values 1 2 3) (values x y z)))

Since CONS is an ordinary function it ignores extra values of its
arguments, this is equivalent to

(setf (values x y z) (cons 1 x)) ==
(multiple-value-setq (x y z) (cons 1 x))

which produces the ACL result.

Allowing VALUES in SETF was a pretty late addition to the standard, and I'm
not sure we thought of all the ramifications like this at the time.

-- 
Barry Margolin, ······@genuity.net
Genuity, Woburn, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.
From: Paul Dietz
Subject: Re: setf-like forms on VALUE places
Date: 
Message-ID: <3DB84634.3C69B0CA@motorola.com>
Barry Margolin wrote:
 
> Most of these other forms are defined in terms of simpler forms, e.g.
> 
> (push x place) == (setf place (cons x place))

That's consistent, but not terribly useful.  I had hoped
the intent would have been more like (up to evaluation
ordering and temporary variable naming):

   (push <form> (values <place1> ... <placen>)) ==
   (multiple-value-bind (t1 ... tn)
       <form>
     (values
      (push t1 <place1>)
      ...
      (push tn <placen>)))

There's no loop required, except in the setf expander.

I'm going to view this as an area where the spec just
didn't get fully baked.

	Paul