Alternation already exists, at least at the outer level:

macro_rules! alt_example(
    ( cons($e1:expr, $e2:expr) ) => ( ... )
    ( mt() ) => ( ... )
)

Of course, making use of it for something other than a whole macro
invocation requires the use of a helper macro, which can be tricky if the
helper macro wants to be invoked somewhere that macro invocations can't yet
go.

There's generally some way around this sort of problem, typically involving
continuation-passing-style at the macro level. Since you can't generate
patterns, you'll want to generate a whole match (as you are doing), and
since you want to process each arm on its own (in order to do
pattern-matching), you'll want to process one at a time, accumulating your
work into some sort of accumulator argument. Abusing repetition to get
around this is probably equally legitimate.

Paul
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to