Emulation macros and pattern matching on D
Dennis Ritchie via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Fri Jun 5 06:01:12 PDT 2015
Macros and operation of pattern matching `=>` in Rust I can write
something like this:
macro_rules!foo {
(x => $e:expr) => (println!("mode X: {}", $e));
(y => $e:expr) => (println!("mode Y: {}", $e));
}
fn main() {
foo!(y => 3); // mode Y: 3
foo!(x => 2); // mode X: 2
}
How is it possible to simulate in D?
More information about the Digitalmars-d-learn
mailing list