IIRC there’s new macro surface syntax coming in Rust 1.31. Where would I be able to read up on how that interacts with the just-stabilized procedural macros?
That’s assuming they even interact, and that macro not simply a replacement for macro_rules! that can also do procedural macros…somehow.
See that's the confusing part: the declarative macro facility seems to support a procedure-like form, aside from a pattern-matched, macro_rules!-like form.
What I'm after in this case is insight into the relation (if any) between the procedure-like macro form, and procedural macros (i.e. the feature stabilized in 1.30).
If there's no relation between the 2 then I'd like to know the purpose/motivation of the procedure-like macro form.
Can you explain the unhygeine of macro_rules! a bit more? Rust macros are often introduced as hygenic, and I haven't seen unhygeine from them in practice.
I see the second form I provided above replacing macro_rules, and that is not surprising as its grammar is pretty similar to that of macro_rules (except for an annoying difference in how macro expansion body blocks are ended: with a semicolon vs a comma, that also behave differently in what usage they find correct).
In this thread I’m more concerned with the first syntactic form. Is that meant to become sugar for the just-stabilized proc-macro’s?
BTW, for an additional, real world macro problem I’ve run into is that macro’s can’t nicely define other macros that have some of their definition handed down to them by virtue of being defined by the first macro rather than simple argument passing (I’ll call these closure-like macros, as they’re analogous to closures in the general sense). That’s to say, they can define them, but not without leaking weird impl details to the top level macro, at the very least the $ sign in something like \$(...) * for matching multiplicities with kleene operators.
While not a hygiene issue in the traditional symbol clash sense, I’d definitely call this a hygiene issue.
is just another way to declare pattern matching macros with only one arm. (Potentially they could give better errors than “no arm expected” based on only having one arm?)
IIRC, the format of decl_macro hasn’t gone through an RFC yet and merely exists to have something to experiment with declaritive macros 2.0 in.
(macro macros will replace macro_rules! macros when macros 2.0 becomes a thing in the far future.)
Supported in Nightly but not stable, right? As @CAD97 said the syntax is not settled yet.
Either way, when you said “procedure-like” I was thinking of procedural macros that take and return a TokenStream, and run arbitrary code. This syntax may be somewhat similar to function definition syntax (with a name followed by parameters in a pair of parenthesis) but it is still definitely declarative: the expansion is // macro contents with simple substitution.