Macro Keyword

This collapsed part is off-topic, as is a huge part of the post I'm responding to!

I don't think this is entirely fair. At least speaking for myself I am just trying to help OP understand the shortcomings of their concrete proposal (letting other tokenizers take over) and presenting what's currently already possible. This does not mean there is no need for anything else.

Your interpretation of OP's idea seems like an entirely different proposal to me. OP was explicitly not only asking about more rust-like styles of macro-invocation like weird_struct! Foo { } where the parentheses only contain rust-tokens again. This only became clear because of additional questions answered by OP. Without questioning him/her, it would be impossible to really understand their point.

If there are problematic individual responses, point them our, flag them but don't blame the whole thread.

Exploring other possibilities that are useful must start close to what already is possible. If we want to use macros for non-Rust-like languages using some_macro!{r#" ... "#} is currently lexically possible but not really nice to read. Especially the parantheses seem superflous, I would like at least some_macro!r#" ... "# to work.

Going further, one could think of syntax analogous to raw strings with a delimiter, compare to other languages and discuss ideas like parsing multiple token trees on macro-invocation in item-position until the first semicolon or braced token-tree to get more Rust-keyword-like behavior.

Speaking of other languages, for example Haskell has so-called Quasiquotes which look like [some_ident| ... |] where ... cannot contain any |] and where some_ident is some(thing like a) macro definition that gets passed the ... verbatim as a stream of characters.

7 Likes