guile-user
[Top][All Lists]
Advanced

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

Re: question about values


From: Matt Wette
Subject: Re: question about values
Date: Wed, 18 Mar 2020 05:39:22 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1



On 3/18/20 2:55 AM, Massimiliano Gubinelli wrote:
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

(begin
  (initialization-code)
  (let ((ret (bar)))
   (finalization-code)
   ret))


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



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




reply via email to

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