3 comments

[ 3.8 ms ] story [ 19.9 ms ] thread
I use macros in Racket, and generally the idea is that they mix with the language until its not clear which are the language constructions and which are the user defined macros.

For example, instead of

  pub static SMITHY: Card = action! { "Smithy" costs 3 and calls do_smithy };
I’d written it as

  pub static SMITHY: Card = action! { "Smithy", 3, do_smithy };
Is this possible in Rust, or comas are special?
Since Rust macros MUST end with a !, it's easy to tell what is a macro and what is not.
It's absolutely possible. I actually implemented it the way I did more as an experiment to see if it was possible, and when it turned out that it was, decided that it was ridiculous enough to be awesome.

I probably wouldn't ever use a macro like this in code worked on by multiple people, but for my own personal side project, I'm happy to abuse Rust's flexibility for my own enjoyment.