<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On 13 Dec 2021, at 21:04, Marco Antoniotti <<a href="mailto:marco.antoniotti@unimib.it" class="">marco.antoniotti@unimib.it</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="">Hi</div><div class=""><br class=""></div><div class="">apologies for the stupid question. I was reviewing some teaching material and looked at the following Scheme (form SICP) code about "streams".</div><div class=""><br class=""></div><div class="">
<span style="font-family: monospace; font-size: inherit; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; background-color: rgb(255, 255, 255); display: inline; float: none;" class="">(define (integral integrand initial-value dt)</span><span style="font-family: monospace; font-size: inherit; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; background-color: rgb(255, 255, 255); display: inline; float: none;" class=""><br class=""> (define int</span><br style="font-family: monospace; font-size: inherit; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; background-color: rgb(255, 255, 255);" class=""><span style="font-family: monospace; font-size: inherit; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; background-color: rgb(255, 255, 255); display: inline; float: none;" class=""> (cons-stream initial-value</span><br style="font-family: monospace; font-size: inherit; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; background-color: rgb(255, 255, 255);" class=""><span style="font-family: monospace; font-size: inherit; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; background-color: rgb(255, 255, 255); display: inline; float: none;" class=""> (add-streams (scale-stream integrand dt)</span><br style="font-family: monospace; font-size: inherit; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; background-color: rgb(255, 255, 255);" class=""><span style="font-family: monospace; font-size: inherit; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; background-color: rgb(255, 255, 255); display: inline; float: none;" class=""> int)))</span><br style="font-family: monospace; font-size: inherit; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; background-color: rgb(255, 255, 255);" class=""><span style="font-family: monospace; font-size: inherit; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; background-color: rgb(255, 255, 255); display: inline; float: none;" class=""> int)</span>
</div><div class=""><br class=""></div><div class="">The question is how you'd rendered it in Common Lisp or how you would provide some macrology to mimic the inner <span style="font-family:monospace" class="">define</span>. I know this has been asked before... I am sure somebody knows the answer.</div><div class=""><br class=""></div></div></div></blockquote><br class=""></div><div>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.</div><div><br class=""></div><div>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).</div><div><br class=""></div><div>Pascal</div><div><br class=""></div></body></html>