I know this might seem very trivial, but can someone please tell me how the
keyword "values" returns its arguments. Is it possible to capture these two
in a list? Whenever I tried to, all I could capture was the first value.
Any response would be greatly appreciated.
Thanks
Ben
On Sat, 6 Jul 2002 11:12:44 -0400, Ben Good <········@hotmail.com> wrote:
>I know this might seem very trivial, but can someone please tell me how the
>keyword "values" returns its arguments. Is it possible to capture these two
>in a list? Whenever I tried to, all I could capture was the first value.
>Any response would be greatly appreciated.
>
Multiple return values are received using the multiple-value-bind
macro. You can capture an arbitrary number of multiple values with
the multiple-value-list macro.
As to how they are returned, they might be returned in registers, on
the stack, or in the heap :)
Tim
In article <···················@news.webusenet.com>, Ben Good wrote:
> I know this might seem very trivial, but can someone please tell me how the
> keyword "values" returns its arguments.
A values expression takes its arguments and turns them into a multiple value. A
multiple value is a special mechanism built into Lisp; multiple values are not
lists and they are not arrays. They are little leprechauns; if you don't
capture them when they are returned, they vanish. You cannot obtain a
reference to the aggregate that represents multiple values. This is a very
beautiful thing, because the Lisp implementation can stack-allocate the cells
that hold multiple values.
> Is it possible to capture these two
> in a list? Whenever I tried to, all I could capture was the first value.
> Any response would be greatly appreciated.
To capture the multiple values coming out of the evaluation of a form,
you must use one of the macros for that purpose. Take your pick:
multiple-value-bind captures multiple values as variable bindings
multiple-value-setq captures values by assignment to variables
multiple-value-list captures them by consing up a list
multiple-value-call bounces multiple values as args to a function
Hope this helps.