Naming methods from strings using mixin
Robert Rouse
robert.e.rouse at gmail.com
Tue Feb 21 06:53:05 PST 2012
Using a mixin, is it possible to have it define a method based on
a string passed into the mixin?
An example of what I'm hoping to do:
mixin template make_method(string name) {
void name() { // not sure how to make it become "void
bark()" here
writeln("hello");
}
}
class Animal {
mixin make_method!("bark");
}
Animal a;
a.bark();
Any help would be appreciated. I'm hoping D can do this since it
would make something I'm trying to do easier.
More information about the Digitalmars-d-learn
mailing list