reference to 'self' inside a function
Philippe Sigaud
philippe.sigaud at gmail.com
Sun Sep 23 12:58:40 PDT 2012
On Sun, Sep 23, 2012 at 7:16 PM, Ben Davis <entheh at 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!
More information about the Digitalmars-d
mailing list