reference to 'self' inside a function
angel
andrey.gelman at gmail.com
Wed Jul 18 00:08:41 PDT 2012
> You could always use __FUNCTION__ in a string mixin, but that
> _is_ rather ugly.
Like this ?
auto fac = delegate(int n) {
if (n <= 1)
return 1;
return n * mixin(__FUNCTION__)(n - 1);
};
Well, there are a few problems with this:
- it _is_ ugly
- some 'automatic' name should be generated internally (possibly
it is in any case)
- it doesn't currently work
Possibly more streamlined approach would be:
thisFunc (or 'self', or whatever)
thisFunc.stringof istead of __FUNCTION__
More information about the Digitalmars-d
mailing list