Skip to content

Qi Compiler Sync Nov 29 2022

Siddhartha Kasivajhula edited this page Dec 15, 2022 · 6 revisions

Declaring Binding Rules

Qi Compiler Sync Nov 29 2022

Adjacent meetings: Previous | Up | Next

Summary

We declared some scoping rules for bindings in the expander.

Background

Last time, we discussed possible scoping rules for the language. We decided to start with conservative scoping rules that signal an error if we cannot guarantee at compile-time that bindings will be defined at the site where they're used.

Declaring Scoping Rules

We declared the rules in Qi's syntaxspec (the artist formerly known as bindingspec) grammar. To do this, we defined a binding-floe nonterminal to define the scoping rules for forms that may involve bindings. Currently, the only Qi form (aside from the binding form as itself) that needs to declare such scoping rules is ~> -- the rule being that bindings in earlier flows in the sequence bind identifiers in later flows in the sequence. All of the other forms (besides ~> and as) were placed in a new simple-floe nonterminal, which doesn't declare any special scoping rules. The original floe nonterminal could be either of these (though for implementation reasons it is declared as only being the former, which itself declares the latter as a fallback case).

This commit shows the changes that we made today, and contains some explanatory comments.

Next Steps

  • Michael will be adding a new (host ...) form to syntaxspec to declare subexpressions in the DSL that are host language expressions. This will allow us to leverage this information in the compiler to solve the "unbounded nesting" problem (mentioned in previous meeting notes).
  • Implement support in the compiler for binding multiple values using the as form.

Notes

This was moved to Tuesday from the usual Friday meeting time to accommodate schedules. We return to the usual Friday meeting time next week.

Attendees

Michael, Sid

Clone this wiki locally