Is this macro syntax possible: macro![a,b]{ /* ... */ }


I have a macro that’s used like this:

external_function(a.as_mut_ptr(), b.as_mut_ptr());
validate![a, b];

Would it be possible to rearrange it to something more like:

validate![a,b] {
    external_function(a.as_mut_ptr(), b.as_mut_ptr());


No. You get one group ((..), [..], {..}) as argument to a macro. Best you can do is nest everything in another, outer group.


Thanks. Wrapping it may be the best option then. I just want to make the relationship more obvious in some way.


At some point in the future it may be possible to write

#[validate(a, b)] {
    external_function(a.as_mut_ptr(), b.as_mut_ptr()); 

(I tried to test whether attribute proc macros are accepted in this position, but I can’t even figure out which unstable features I need to activate anymore…)

Edit: Okay, I tested it. Yes, support for proc macros in this position is implemented, but there are currently two features you have to toggle just for that:

extern crate procm;
use procm::attr;

fn main() {
    #[attr(a, b)] {
        let a = 3;

In any case, it’s not in the subset of proc macro features that are going to be stabilized soon.