aboutsummaryrefslogtreecommitdiffstats
path: root/csc/loop.csc
diff options
context:
space:
mode:
authorRose Hogenson <rhogenson@posteo.net>2022-06-28 15:58:36 -0700
committerRose Hogenson <rhogenson@posteo.net>2022-06-28 15:58:36 -0700
commitfed28363fb60266c030a0f6b30d5a9d697774ee0 (patch)
tree50ed1ec9663371220559e4d4bfc7b1cd1bcb7117 /csc/loop.csc
parentFinish CPS. (diff)
downloadchromatopelma-fed28363fb60266c030a0f6b30d5a9d697774ee0.tar.zst
Improve CPS.
Goodbye soup. Thanks to "Compiling with Continuations" by Appel.
Diffstat (limited to 'csc/loop.csc')
-rw-r--r--csc/loop.csc3
1 files changed, 2 insertions, 1 deletions
diff --git a/csc/loop.csc b/csc/loop.csc
index a323495..dbd6200 100644
--- a/csc/loop.csc
+++ b/csc/loop.csc
@@ -88,12 +88,13 @@
clause* ...)))
((loop-aux "variable-clause-collector" ((body ...) fin) for x = init then subseq clause* ...)
(let ((first #t)
+ (init-value (lambda () init)) ; put the body of init outside the scope of x.
(x #f))
(loop-aux "variable-clause-collector"
((body ... (if first
(begin
(set! first #f)
- (set! x init))
+ (set! x (init-value)))
(set! x subseq)))
fin)
clause* ...)))