guile-devel
[Top][All Lists]
Advanced

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

Re: Storing multiple values in a single variable


From: Andy Wingo
Subject: Re: Storing multiple values in a single variable
Date: Tue, 17 Mar 2009 00:11:50 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.91 (gnu/linux)

Hi Ludovic,

On Mon 16 Mar 2009 23:16, address@hidden (Ludovic Courtès) writes:

>   scheme@(guile-user)> ,o interp #t
>   scheme@(guile-user)> (define v (values 0 1 2 3))

Here you enter territory that is explicitly undefined by the Scheme
spec (R5 and R6, I think).

>   scheme@(guile-user)> ,o interp #f
>   scheme@(guile-user)> (define v (values 0 1 2 3))

Here as well. What the VM does was a conscious decision, to discard
extra values. So `v' is now 0.

>   scheme@(guile-user)> (let-values (((a b c d) v)) (list a b c d))

And obviously v is not a MV-producing expression.

> OTOH, I suspect that the effect of storing multiple values in a single
> variable is not specified anyway. (FWIW, Bigloo discards all values but
> the first and Ikarus throws an error.)

There are two things that an implementation might sensibly choose to do
when more values than expected are returned to a continuation:

  - Error.

  - Truncate the values to the number that was expected.

Guile does neither :) Which has its uses, I guess, but it prevents
efficient implementation. On the VM, returning multiple values is really
cheap. There's no consing involved.

So I would say about this: we can probably deal with it. It's
unspecified anyway, and is really an edge case.

Happy hacking,

Andy
-- 
http://wingolog.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]