-
Notifications
You must be signed in to change notification settings - Fork 13
Description
Mike ran into this trying to support Racket subexpressions in the multi-pass ANF compilation example.
Racket references to DSL variables
Expansion of the Racket subexpressions is delayed, so they don't get renamed in each pass. Thus when we finally expand them as part of the final compilation, or as part of an analysis like get-racket-referenced-identifiers in a later pass, they only rename once via the reference compiler. The final name they reach is one that only had a binder in an intermediate syntax.
Possible solutions:
- Require that compiler passes
local-expandthe Racket subexpressions to keep them in lockstep. (Wouldlocal-expandof the renamed reference fail because the binder is not yet present?) - Change
compile-referenceto follow a chain ofcompiled-idsentries. - Change
binding-as-rkt(the implementation of reference compilers) to iterate the call tocompile-reference(perhaps via acompile-reference*helper to follow a chain ofcompiled-idsentries.
I prefer option 3. I don't think that reference compilation outside of reference compilers should iterate the lookup, because that could hide mistakes in a DSL compiler implementation where renaming isn't run on all portions of the program the same number of times.
Return to DSL code inside the Racket subexpression
What if the host expression contains not only a reference to a DSL variable, but a whole DSL fragment that requires its own multi-pass compilation? We currently don't have a means to line up the passes of compilation for this inner fragment with the the corresponding passes for the outer fragment. A get-racket-referenced-identifiers would force the complete compilation of the inner syntax, which would ultimately fail because the binders for the compiled free references would not be bound yet.
For now, I think we should try and solve the first problem with option 3 and accept the second problem as a limitation.