Yes. Sorry. My bad, I had coded by copy&paste my previous example and is obviously not going to work.
Indeed dynamic-wind works as it should: 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 () (values "a" "b" "c")) (lambda () (display "finalize\n")))) (lambda body body)) initialize finalize $2 = ("a" "b" "c") It seems to me a very good solution to my problem. Thanks a lot to all! Max > On 18. Mar 2020, at 16:08, to...@tuxteam.de wrote: > > On Wed, Mar 18, 2020 at 03:48:03PM +0100, Massimiliano Gubinelli wrote: >> >>> On 18. Mar 2020, at 15:40, Massimiliano Gubinelli <m.gubine...@gmail.com> >>> 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)) > ^^^^^^ HERE >> (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. > > Above, marked with HERE is the crocodile eating > your other values. > > If you instead do, in that line > > (lambda () (values "a" "b" "c")) > > then you get ("a" "b" "c"). > > The let binding construct only binds one value. There's a > "let-values" for that. > > Cheers > -- tomás