Draft: Basic scaffolding for Closure-Passing Style #54
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Converting our AST into a Closure-Passing Style IR is an absolute must for this project to be at all useful in any real context. Therefore, with a lot of the core functions implemented, I think now is as good of a time as any to start working on this.
The first goal should be to get CPS compiling to IR in a not-very-optimized but completely functional way. I.e., all functions are compiled, but there are no significant optimizations done on the IR, the functions always return thunks, and trampolining is done in Rust. Not exactly sure how that is going to work with async, maybe I just ignore functions that
await for now.
Poorly optimized CPS is still likely to be faster than the interpreter, and will have the added benefit of allowing continuations to be implemented mechanically, rather than manually. The goal primary goal of this branch is to eliminate the
continuation.rs
module entirely.Once that is done, I will have more confidence moving forward implementing the rest of R6RS. Then the fun part - optimizing the crap out of everything.
Things to do in the process of completing this:
perform escape analysis to determine which functions need closures and which do not.as a first pass, every function will be considered escaping.