Patrick proposed a new syntax for macro invocations. Summary from
https://github.com/graydon/rust/wiki/Syntax-extension:
Expr → "#" Path BalancedLexemes
BalancedLexemes → "(" BalancedLexemes * ")"
BalancedLexemes → "[" BalancedLexemes * "]"
BalancedLexemes → "{" BalancedLexemes * "}"
BalancedLexemes → AnyOtherLexeme
The macro system will need a way to call back into the parser to turn the
lexemes into actual syntax. This is non-trivial, especially ergonomics-wise,
but should be doable, and would allow for a great deal of flexibility in
macro definition.
Interleaving parsing and expansion makes it a bold plan. I can't possibly
get it done before I have to go. But what do people think about this idea in
principle?
We previously rejected such interleaving because they would make external
tools impossible to write. But, with the requirement of balanced delimiters,
it's always possible to find the end of a macro invocation. The invocation
itself is a syntactic black hole, but this would be the case anyways (we
would lose the ability to identify where the expressions are in the macro
arguments, but that doesn't really matter, since tools can't use that
information anyways). The best-effort syntax highlighting Emacs and Vim do
would usually do the right thing.
Any immediate thoughts?
Thanks for the use of your brains,
Paul
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev