Denis Koroskin wrote: > On Sat, 28 Feb 2009 23:39:41 +0300, Andrei Alexandrescu > <[email protected]> wrote: > >> Nick Sabalausky wrote: >>> "dsimcha" <[email protected]> wrote in message >>> news:[email protected]... >>>> == Quote from Jarrett Billingsley ([email protected])'s >>>> article >>>>> Can we get this please? It's so simple and would be terribly useful. >>>> Can someone explain what __FUNCTION__ would do in a little more >>>> detail? I feel >>>> like the two posts of this thread so far are talking in secret >>>> __FUNCTION__-dealer >>>> code. >>> void foofunc() >>> { >>> Stdout.formatln("{}", __FUNCTION__); >>> } >>> Output: >>> foofunc >>> Ie, basically the same as __FILE__ and __LINE__ and useful in the same >>> ways. >> >> I think instead of __FUNCTION__ we'll define a much more comprehensive >> static reflection facility. >> >>> Also, I'd like to be able to do something like: >>> Reflect.invoke(__FUNCTION__, params); >> >> Yah... and Variant needs to have something similar as well. We know >> quite what std.reflect needs to look like, just we want to keep our >> fingers out of too many pies at once. >> >>> Something funtionally equiveilent to that would aid maitenance of >>> self-invoking functions (not only recusion, but also func overloads >>> that are defined in terms of one "primary" overload). >>> Also would be nice for similar reasons: __CLASS__ (or something >>> similar that would also work for structs) >> >> Yah. >> >> Andrei > > Yes. When writing a recursive function, it is often desired to have a way > to call the function recursively via some shortcut, something like 'fthis' > (this function). It would be great to have something like this in D. That > way _FUNCTION__ could be replaced by 'fthis.stringof' or something > similar. It also gives small other advantages (easier code refactoring > etc). Here is an example: > > int factorial(int c) > { > //writefln(fthis.stringof); > //writefln(typeof(fthis).stringof); > > if (c < 2) return 1; > return fthis(c - 1) * c; > }
"fthis" does not sounds like a nice keyword. How about "self"?
