On 23/09/2012 20:58, Philippe Sigaud wrote:
On Sun, Sep 23, 2012 at 7:16 PM, Ben Davis <ent...@cantab.net> wrote:
Here's another one that might work, and be less error-prone:
mixin template Self() {
auto self = __traits(identifier, __traits(parent, {}));
}
void test() {
mixin Self;
writeln(self);
}
Oh, you're using {} as a local block (or anonymous delegate), right?
That's a nice trick.
I even works at the module level, nice one!
Actually I stole the {} from Nick's suggestion. My suggestion was using
a mixin template instead of a string mixin, making it harder to screw up
invoking the mixin :)