guile-user
[Top][All Lists]
Advanced

[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 15:48:03 +0100

> On 18. Mar 2020, at 15:40, Massimiliano Gubinelli <address@hidden> wrote:
> 
> Good point with dynamic-wind. Does it pass along also multiple values or has 
> the same problem?
> 

Does not work...

mgubi@Ulrike guile3-usr % bin/guile
GNU Guile 3.0.1
Copyright (C) 1995-2020 Free Software Foundation, Inc.

Guile comes with ABSOLUTELY NO WARRANTY; for details type `,show w'.
This program is free software, and you are welcome to redistribute it
under certain conditions; type `,show c' for details.

Enter `,help' for help.
scheme@(guile-user)> (call-with-values (lambda ()
 (dynamic-wind (lambda () (display "initialize\n"))
  (lambda () (let ((a (values "a" "b" "c"))) a))
  (lambda () (display "finalize\n"))))
  (lambda body body))
initialize
finalize
$1 = ("a")
scheme@(guile-user)> 

Isn't this a bug??? In my view it breaks composability of scheme code.

Best,
Max



> m
> 
> 
>> On 18. Mar 2020, at 15:06, John Cowan <address@hidden> wrote:
>> 
>> There is going to be a performance penalty, because you are taking multiple 
>> values (which is not a value) and making it into a value by creating a list. 
>>  There is no getting away from that except to exclude multiple values.
>> 
>> Note also that if the procedure throws an exception, your finalizer will 
>> never be run.  Consider using dynamic-wind, whose whole purpose is to make 
>> sure that an initializer and a finalizer are always run.
>> 
>> On Wed, Mar 18, 2020 at 9:11 AM Massimiliano Gubinelli <address@hidden> 
>> wrote:
>> 
>> > On 18. Mar 2020, at 13:39, Matt Wette <address@hidden> wrote:
>> > 
>> > 
>> > How about calling (my-macro/values bar) where my-macro/values expands to
>> > 
>> > (call-with-values (lambda () (bar))
>> >   (lambda args (finalization-code) (apply values args))
>> > 
>> > Matt
>> > 
>> > 
>> 
>> Yeah! I like this better. But still wraps and unwraps the result.
>> 
>>  Is there any performance penalty in that? 
>> 
>> Apart from my specific user case I wonder how and why in general multiple 
>> values are used. Seems they are not well integrated in the current Guile 
>> implementation. In my naive opinion the behaviour of Guile 1.8 was more 
>> consistent.
>> 
>> Max
>> 
>> 
>> 
> 




reply via email to

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