"gensym" in the left parts of macro rules

This comment told about inability to make variable number of new identifiers in macros:

You can't create new idents because of hygiene, so expanding generic functions is kind of impossible

Is it a good idea to have a sort of $x:gensym thing, like this:

macro_rules! qqq {
    [ $( $x:ident $t:gensym),* ] => { $( let $t = $x;  )*; }
}

qqq!{ foo, bar};

?

$x:gensym should work like $x:ident, but without user actually specifying anything in that place, like a non-consuming regular expression part. Compiler should generate a random unique identifier name for this instead.

gensym has been discussed in rfc#1266. But an early-expanding concat_ident! (RFC 1628) would be a more general solution.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.