Quoting is currently impossible for code fragments which are only part of a larger expression.
Consider quote { foo: 1 + 1 } which would currently fail since foo: 1 + 1 is only valid as part of a constructor initializer expression's inner field expressions. The current approach to getting this working would require we introduce a new quoted type for each parser rule we want to support this way, which is infeasible.
Happy Case
Add the ability to quote token streams which aren't parsed until they're inserted at a macro's call site. This way users can quote any snippet of code, even ones that are temporarily invalid until they are fixed later or combined with other snippets.
Since token streams are essentially a list of tokens I'm thinking it'd be useful to expose them directly as such. Instead of a Quoted type we could have [Symbol] for a slice of individual words/symbols.
Problem
Quoting is currently impossible for code fragments which are only part of a larger expression.
Consider
quote { foo: 1 + 1 }
which would currently fail sincefoo: 1 + 1
is only valid as part of a constructor initializer expression's inner field expressions. The current approach to getting this working would require we introduce a new quoted type for each parser rule we want to support this way, which is infeasible.Happy Case
Add the ability to quote token streams which aren't parsed until they're inserted at a macro's call site. This way users can quote any snippet of code, even ones that are temporarily invalid until they are fixed later or combined with other snippets.
See https://github.com/noir-lang/noir/issues/4594#issuecomment-2176746959 for more details
Project Impact
None
Impact Context
No response
Workaround
None
Workaround Description
No response
Additional Context
No response
Would you like to submit a PR for this Issue?
None
Support Needs
No response