[Issue 5140] Add __FUNCTION__, __PRETTY_FUNCTION__, and __MODULE__

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Jan 12 10:42:16 PST 2013


http://d.puremagic.com/issues/show_bug.cgi?id=5140



--- Comment #21 from Andrej Mitrovic <andrej.mitrovich at gmail.com> 2013-01-12 10:42:15 PST ---
(In reply to comment #8)
> But they are also related, as you can implement anonymous recursion with
> __FUNCTION__:
> 
> 
> long fact(long n) {
>     if (n <= 1)
>         return 1;
>     else
>         mixin("return n * " ~ __FUNCTION__ ~ "(n - 1);");
> }

This is unreliable. If `fact` is nested inside of a mixin template you won't be
able to call the function this way. On another note this has uncovered a new
ICE in Issue 9182.

It's also very untidy to have to use mixins and string representation for
recursive calls. It's much simpler to use 'return __function(n - 1)'.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list