From: Philippe Lorin
Subject: multiple-value-bind only accepts symbols
Date: 
Message-ID: <435378a1$0$1235$626a14ce@news.free.fr>
Is there a reason multiple-value-bind only accepts symbols, not places? 
And what would be the best way to do the equivalent with places? I can 
write this, but it's a bit ugly:

(let ((a-and-b (multiple-value-list
                 (some-function-that-returns-two-values))))
   (setf (slot-a x) (first a-and-b))
   (setf (slot-b x) (second a-and-b)))


I'd much rather have something that would look like this:

(multiple-value-bind-extra ((slot-a x) (slot-b x))
     (some-function-that-returns-two-values))


Of course I can define multiple-value-bind-extra, but before doing that 
I wanted to know if something alike did not exist already.

From: Juho Snellman
Subject: Re: multiple-value-bind only accepts symbols
Date: 
Message-ID: <slrndl6vp5.r80.jsnell@sbz-30.cs.Helsinki.FI>
<············@gmail.com> wrote:
> Is there a reason multiple-value-bind only accepts symbols, not places? 
> And what would be the best way to do the equivalent with places? I can 
> write this, but it's a bit ugly:
> 
> (let ((a-and-b (multiple-value-list
>                  (some-function-that-returns-two-values))))
>    (setf (slot-a x) (first a-and-b))
>    (setf (slot-b x) (second a-and-b)))

Because that's not what binding means (have a look at the CLHS glossary).
The less ugly way to write this is:

(setf (values (slot-a x) (slot-b x)) 
      (some-function-that-returns-two-values))

-- 
Juho Snellman
"Premature profiling is the root of all evil."
From: Philippe Lorin
Subject: Re: multiple-value-bind only accepts symbols
Date: 
Message-ID: <43538751$0$28019$626a14ce@news.free.fr>
Juho Snellman wrote:
> Because that's not what binding means (have a look at the CLHS glossary).

Ok, but then the question only becomes, why do we have 
"multiple-value-bind" rather than something like "multiple-value-setf". 
But with the solution you provided, I can see that question is stupid.


> The less ugly way to write this is:
> 
> (setf (values (slot-a x) (slot-b x)) 
>       (some-function-that-returns-two-values))

Nice! My mind has not yet been warped enough to the Lisp way so that I 
could think of this by myself. I find this beautiful. Thank you!
From: Peter Seibel
Subject: Re: multiple-value-bind only accepts symbols
Date: 
Message-ID: <m2ll0r7wl2.fsf@gigamonkeys.com>
Philippe Lorin <············@gmail.com> writes:

> Juho Snellman wrote:
>> Because that's not what binding means (have a look at the CLHS glossary).
>
> Ok, but then the question only becomes, why do we have
> "multiple-value-bind" rather than something like
> "multiple-value-setf". But with the solution you provided, I can see
> that question is stupid.

Well, there is MULTIPLE-VALUE-SETQ. However it is generally good style
to do assignments with SETF. I.e. it's better to say (setf (car thing)
10) than (rplaca thing 10) and better to say (setf (values a b) (foo))
than (multiple-value-setq (a b) (foo)).

-Peter

-- 
Peter Seibel           * ·····@gigamonkeys.com
Gigamonkeys Consulting * http://www.gigamonkeys.com/
Practical Common Lisp  * http://www.gigamonkeys.com/book/
From: Pascal Bourguignon
Subject: Re: multiple-value-bind only accepts symbols
Date: 
Message-ID: <87zmp89tap.fsf@thalassa.informatimago.com>
Philippe Lorin <············@gmail.com> writes:

> Is there a reason multiple-value-bind only accepts symbols, not
> places? And what would be the best way to do the equivalent with
> places? I can write this, but it's a bit ugly:
>
> (let ((a-and-b (multiple-value-list
>                  (some-function-that-returns-two-values))))
>    (setf (slot-a x) (first a-and-b))
>    (setf (slot-b x) (second a-and-b)))
>
>
> I'd much rather have something that would look like this:
>
> (multiple-value-bind-extra ((slot-a x) (slot-b x))
>      (some-function-that-returns-two-values))

You want to name it MULTIPLE-VALUE-SETF

> Of course I can define multiple-value-bind-extra, but before doing
> that I wanted to know if something alike did not exist already.

There's already a MULTIPLE-VALUE-SETQ but of course, it only works
with symbols too.

-- 
__Pascal Bourguignon__                     http://www.informatimago.com/
In deep sleep hear sound,
Cat vomit hairball somewhere.
Will find in morning.
From: Marc Ordinas i Llopis
Subject: Re: multiple-value-bind only accepts symbols
Date: 
Message-ID: <1129562511.180713.204010@g14g2000cwa.googlegroups.com>
Would this be enough?

(defmacro multiple-value-setf
    (places form)
  `(setf (values ,@places)
         ,form))

Just a quick answer.

Marc Ordinas i Llopis
From: Pascal Bourguignon
Subject: Re: multiple-value-bind only accepts symbols
Date: 
Message-ID: <87wtkc84yr.fsf@thalassa.informatimago.com>
"Marc Ordinas i Llopis" <····@nexe.org> writes:

> Would this be enough?
>
> (defmacro multiple-value-setf (places form)
>   `(setf (values ,@places) ,form))
>
> Just a quick answer.

Exactly.  This is why it is not included in the standard.

-- 
"Specifications are for the weak and timid!"
From: Barry Margolin
Subject: Re: multiple-value-bind only accepts symbols
Date: 
Message-ID: <barmar-F813A7.15293617102005@comcast.dca.giganews.com>
In article <··············@thalassa.informatimago.com>,
 Pascal Bourguignon <····@mouse-potato.com> wrote:

> "Marc Ordinas i Llopis" <····@nexe.org> writes:
> 
> > Would this be enough?
> >
> > (defmacro multiple-value-setf (places form)
> >   `(setf (values ,@places) ,form))
> >
> > Just a quick answer.
> 
> Exactly.  This is why it is not included in the standard.

Then why is MULTIPLE-VALUE-SETQ included?

IIRC, SETF of VALUES was a late addition to the language.  Before we 
added it, we didn't have MULTIPLE-VALUE-SETF either.

-- 
Barry Margolin, ······@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***