Scheme like question

Pascal Costanza pc at p-cos.net
Mon Dec 13 20:58:58 UTC 2021



> On 13 Dec 2021, at 21:04, Marco Antoniotti <marco.antoniotti at unimib.it> wrote:
> 
> Hi
> 
> apologies for the stupid question.  I was reviewing some teaching material and looked at the following Scheme (form SICP) code about "streams".
> 
> (define (integral integrand initial-value dt)
>   (define int
>     (cons-stream initial-value
>                  (add-streams (scale-stream integrand dt)
>                               int)))
>   int)
> 
> The question is how you'd rendered it in Common Lisp or how you would provide some macrology to mimic the inner define.  I know this has been asked before...  I am sure somebody knows the answer.
> 

The inner define needs to receive the remainder of the body of the outer define as one of its arguments. Common Lisp’s defmacro sees only arguments passed directly to the macro itself, not whatever comes after the macro invocation.

The only way to solve that is that the outer define parses its body and looks for inner defines, and then rearranges the forms into the proper binding forms (letrec* in Scheme, let*/labels in Common Lisp, depending on which namespace you want to affect).

Pascal

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/pro/attachments/20211213/cc02511a/attachment.html>


More information about the pro mailing list