tail-recursive interpreteded for loop

This commit is contained in:
2025-11-14 16:15:27 -06:00
parent 3c9600dd5f
commit cb4f6b0d4a

View File

@@ -54,16 +54,15 @@
iter (collection.iterator)]
(dictSet (last localScopes) "__iter__" iter)
(localFunction run []
(if (iter.hasNext)
(evalCC (callSymbol "let" (.concat [(listExp [varName (callSymbol "__iter__.next" [])])] body))
->v {(when collect
(results.push v))
(run)
})
{
(localScopes.pop)
(cc results)
}))
// Oof -- everything needs to be synchronous
(unless (iter.hasNext)
(localScopes.pop)
(cc results)
(return))
(evalCC (callSymbol "let" (.concat [(listExp [varName (callSymbol "__iter__.next" [])])] body))
->v (when collect
(results.push v)))
(run))
(run)))))
(method makeFunction [:Array<ReaderExp> argExps :Array<ReaderExp> bodyExps]