[Top][All Lists]

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

Re: question about values

From: Massimiliano Gubinelli
Subject: Re: question about values
Date: Wed, 18 Mar 2020 10:55:32 +0100

Thanks Taylan,

> On 18. Mar 2020, at 07:12, Taylan Kammer <address@hidden> wrote:
> On 18.03.2020 00:50, Massimiliano Gubinelli wrote:
>> (let ((a (values "a" "b" "c"))) a)
> The result of (values x y z) is not a kind of object that contains three 
> values (like a list or vector).  It's three separate values that would need 
> to be put into three separate variables.  But you're only naming one variable 
> (a).  So strictly speaking the code is "wrong".
> In Guile 1.8, multiple values were actually put into some special kind of 
> object (which was not very efficient) so code like that still somehow worked 
> even thought it's technically wrong.
> Starting from Guile 2.0, providing multiple values in a context where only 
> one is expected causes the extra values to be ignored.

I understand the point but then it comes to the problem how to handle this in 
macros. For example if bar is a proceduce which returns multiple values and I 
have a macro "my-macro" which wraps the call with some initialization and 
finalization code and I write

(my-macro (bar))

how to write this macro without knowing if bar is returning multiple values or 
not? For example I would like the code above to expand into

 (let ((ret (bar))) 

But this does not work as shown by the example above. How to implement this 
macro correctly?


> Happy to answer further questions about this.  Multiple-values can be a 
> tricky concept to grasp because most other programming languages don't have 
> it.
> - Taylan

reply via email to

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