masak / alma

ALgoloid with MAcros -- a language with Algol-family syntax where macros take center stage
Artistic License 2.0
138 stars 15 forks source link

Rethink "source of truth" for Q::Identifier #382

Open masak opened 6 years ago

masak commented 6 years ago

We know more about identifiers nowadays. This knowledge hasn't really found its way back into the design of Q::Identifier. Maybe it should, and maybe that would make some problems we're currently facing easier to solve.

So. There are two types of identifier:

masak commented 6 years ago

Having written #410, I'm more convinced we need to do this anyway to get that semantics/implementation.

Because of the "leapfrogging" example in #410 (you can Ctrl+F for it), I don't think it's a good idea for lexical identifiers to use the (n, i) tuples as their source of truth — because injected code from the quasi can invalidate the n — so probably it's better if lexical variables refer to something unique — either the scope, or the declaration itself.

masak commented 5 years ago

372 ties into this, since it wants to tie precedence/associativity information to definition sites. #410 pushes us in the same direction, at compile-time, a variable reference is basically a reference to a definition site, plus a boolean saying whether the reference is unique or not.

The (n, i) tuple we can do, but only after all the macro expansion (and later optimizations) have finished so the references stop moving around in relation to their definitions.