<div dir="ltr"><div>Dear Marc,<br></div><div><br></div><div>Is there any optimization in Gambit that zaps stack frame allocation when not necessary?</div><div><br></div><div>What I'm looking for is that sometimes it's convenient to write code in the format of (1)</div>

<div>below.</div><div><br></div><div>However, as everyone can see, that format implies the allocation of a stack frame on entry</div><div>into the loop, because the loop not is executed in the tail position.</div><div><br>

</div><div>A way to work around that could be to write the code in the format of (2) instead.</div><div>The |at| variable will be GC:ed as soon as it's not referenced anyhow by Gambit thanks to</div><div>the dead variables optimization.</div>

<div><br></div><div>So what I'm looking to understand now is that, if it would be more concise to implement a</div><div>problem in the format of (1), then is that also equally performant in every way as expressing the same problem in the format of (2)?</div>

<div><br></div><div><br></div><div><font face="courier new, monospace">; (1)</font></div><div><font face="courier new, monospace">(begin</font></div><div><font face="courier new, monospace">  [code to run before loop]</font></div>

<div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace">  (let loop ((at something))</font></div><div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace">    (if [not ready]</font></div>

<div><font face="courier new, monospace">        [logic + invocation of loop]))</font></div><div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace">  [code to run after loop])</font></div>

<div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace">; (2)</font></div><div><font face="courier new, monospace">(begin</font></div>

<div><font face="courier new, monospace">  [code to run before loop]</font></div><div><font face="courier new, monospace">  </font></div><div><font face="courier new, monospace">  (let loop ((at something))</font></div><div>

<font face="courier new, monospace">    </font></div><div><font face="courier new, monospace">    (if [not ready]</font></div><div><font face="courier new, monospace">        [logic + invocation of loop]</font></div><div>

<font face="courier new, monospace">        </font></div><div><font face="courier new, monospace">        [code to run after loop])))</font></div><div><br></div><div>Thanks,</div><div>Mikael</div><div><br></div></div>