From: Stefan Nobis
Subject: apply vs destructuring-bind vs multiple-value-bind
Date: 
Message-ID: <87fyrrr0gu.fsf@snobis.de>
Hi.

I have a function returning some values which should be bound at
the calling point to call a function. It looks like this

(defun f () (list 1 2 3))

(defun g (a b c) ...)

(defun h ()
  (destructuring-bind (a b c) (f)
    (g a b c)))

Version B: (defun h () (apply #'g (f)))

Version C:

(defun f () (values 1 2 3))
...
(defun h ()
  (multiple-value-bind (x y z) (f)
    (g x y z)))


Version B is shortest code, but which is most effizient
(speed/memory) and why?

-- 
Stefan.

From: Barry Margolin
Subject: Re: apply vs destructuring-bind vs multiple-value-bind
Date: 
Message-ID: <barmar-3DFC44.23414326092005@comcast.dca.giganews.com>
In article <··············@snobis.de>, Stefan Nobis <······@gmx.de> 
wrote:

> Version B is shortest code, but which is most effizient
> (speed/memory) and why?

Efficiency is implementation-dependent

-- 
Barry Margolin, ······@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
From: Stefan Nobis
Subject: Re: apply vs destructuring-bind vs multiple-value-bind
Date: 
Message-ID: <87irwn2haq.fsf@snobis.de>
Barry Margolin <······@alum.mit.edu> writes:

> Efficiency is implementation-dependent

OK. So which version would you prefer and why?

-- 
Stefan.
From: Pascal Bourguignon
Subject: Re: apply vs destructuring-bind vs multiple-value-bind
Date: 
Message-ID: <87br2fj990.fsf@thalassa.informatimago.com>
Stefan Nobis <······@gmx.de> writes:

> Hi.
>
> I have a function returning some values which should be bound at
> the calling point to call a function. It looks like this
>
> (defun f () (list 1 2 3))
>
> (defun g (a b c) ...)
>
> (defun h ()
>   (destructuring-bind (a b c) (f)
>     (g a b c)))
>
> Version B: (defun h () (apply #'g (f)))
>
> Version C:
>
> (defun f () (values 1 2 3))
> ...
> (defun h ()
>   (multiple-value-bind (x y z) (f)
>     (g x y z)))

Version D:

  (defun f () (values 1 2 3))
  (defun h () (apply (function g) (values-list 9f)))



-- 
__Pascal Bourguignon__                     http://www.informatimago.com/

In a World without Walls and Fences, 
who needs Windows and Gates?
From: Lars Brinkhoff
Subject: Re: apply vs destructuring-bind vs multiple-value-bind
Date: 
Message-ID: <853bnr9dkr.fsf@junk.nocrew.org>
Pascal Bourguignon <····@mouse-potato.com> writes:
> Version D:
>   (defun f () (values 1 2 3))
>   (defun h () (apply (function g) (values-list 9f)))

Version E:
    (defun f () (values 1 2 3))
    (defun h () (multiple-value-call #'g (f)))