4 ms·
Using and Abusing Macros
- gus_massa 13y agoI 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?
- steveklabnik 13y agoSince Rust macros MUST end with a !, it's easy to tell what is a macro and what is not.
- dradtke 13y agoIt'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.