Dear Marc,
Is there any optimization in Gambit that zaps stack frame allocation when not necessary?
What I'm looking for is that sometimes it's convenient to write code in the format of (1) below.
However, as everyone can see, that format implies the allocation of a stack frame on entry into the loop, because the loop not is executed in the tail position.
A way to work around that could be to write the code in the format of (2) instead. The |at| variable will be GC:ed as soon as it's not referenced anyhow by Gambit thanks to the dead variables optimization.
So what I'm looking to understand now is that, if it would be more concise to implement a 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)?
; (1) (begin [code to run before loop]
(let loop ((at something))
(if [not ready] [logic + invocation of loop]))
[code to run after loop])
; (2) (begin [code to run before loop]
(let loop ((at something))
(if [not ready] [logic + invocation of loop]
[code to run after loop])))
Thanks, Mikael
Afficher les réponses par date