3 ms·
I think you’re missing the complexity of macros: they’re not just Rust or not-Rust, they can mix and match, including using Rust-like syntax. Take this macro st
by chrismorgan 5y ago
I think you’re missing the complexity of macros: they’re not just Rust or not-Rust, they can mix and match, including using Rust-like syntax. Take this macro stub for example (implemented as a procedural macro, if you want to make it harder):
macro_rules! alpha {
(
$(<$($beta:ident),* $(,)?>)?
for $gamma:ty;
$(#[$delta:meta])*
struct $epsilon:ident default $zeta:expr;
## $eta:tt // And I’m not telling you how I’m using this one
$theta:item
) => { … };
}
I can’t see any way to make this work with Analog syntax in such places as $gamma, $zeta and $theta (and who knows about some of the others like $eta?). I’ve made this a fairly extreme example, but simpler examples that are still problematic are widespread.
- asvln 5y agoI think you misunderstood, or I am misunderstanding what you are trying to communicate. There would be no attempt to change any syntax within macro calls. All token trees fed into any macro would be fed directly with the exception of the implied braces when indenting the call.
- chrismorgan 5y agoIn your println! example, you’ve written Analog syntax, but it must be being translated into Rust syntax for the macro to consume. How are you going to decide what to translate and what not to? Perhaps I might put it this way instead: can you write out for me what an invocation of that alpha macro (which is defined in Rust code) from Analog might look like?
- asvln 5y agoYou are absolutely correct, apologies I just saw it now. It was a remnant that got left over. I now see the issue this raises and have discovered a solution through a macro!! call.