-
Notifications
You must be signed in to change notification settings - Fork 13
Qi Compiler Sync Dec 9 2022
Qi Compiler Sync Dec 9 2022
Adjacent meetings: Previous | Up | Next
We completed initial support for binding single and multiple values in Qi!
Last time, we declared scoping rules for bindings in the language. We still needed to:
- Properly discern host language expressions during expansion and compilation to avoid attempting to transform such expressions as part of the bindings implementation (we referred to this as the "unbounded nesting problem" in previous meeting notes)
- Support binding multiple values in the
(as ...)
binding form.
As groundwork for the implementation, Michael added a new racket-var
binding class to syntax-spec ("the artist formerly known as ..." OK I think we all know this at this point). Since Qi's variables are exactly the same as Racket variables, it was no longer necessary to define a custom qi-var
binding class anymore, and we just used this newly created one.
Binding classes are analogous to syntax parameters in that they lend syntax special meaning only in certain contexts and not in others. They can be used to implement nontrivial compilation of bindings, for instance, to constrain the scope of bindings to certain forms. We don't need such customizations in Qi at this time.
Syntax-spec also added a new #%host-expression
tag for components of expressions that are known to be host-language syntax. This supports the compiler handling such forms in a special way. In particular, this allowed us to avoid doing the bindings transformation to binding references when we encountered a host language expression. To do this, we implemented a new find-and-map
function to apply the bindings transformation by walking the tree from the root down to the leaves. This way, we can decide whether to apply the transformation or not depending on whether there is a wrapping #%host-expression
form, addressing (1) above.
We declared in the expander that the as
form can accept any number of identifiers, and then modified the compiler to apply the bindings transformation to each of these identifiers. This now supports (~> (1 2) (as v w) (~a "The sum of " v " and " w " is " (+ v w)))
.
This completes the initial proof-of-concept support for bindings in Qi (pending review and testing, of course)! Next:
- Add docs for syntax-spec, now that it has a name and its syntax has begun to exhibit a certain unity. Michael on the current state of docs: "There are some docs, just no English." [There are formal grammars for various forms 😄]
- Get the bindings PR ready for review towards merging it into the compiler integration branch.
- Review the initial design for bindings and see what other bindings cases we could support next.
- Re-generate the benchmarks showing the performance difference of each Qi form with respect to the main branch, so that we can take stock and start restoring parity towards merging back to main.
Michael, Sid
Home | Developer's Guide | Calendar | Events | Projects | Meeting Notes