On 6/5/15 9:01 AM, Dennis Ritchie wrote:
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?
string foo(string mode, string value)
{
return `writefln("mode ` ~ mode ~ `: %s", ` ~ value ~ `);`;
}
void main()
{
mixin(foo("Y", "3"));
mixin(foo("X", "2"));
}
-Steve