reference to 'self' inside a function

Timon Gehr timon.gehr at gmx.ch
Tue Jul 17 14:08:00 PDT 2012


On 07/17/2012 06:56 PM, angel wrote:
> I propose to introduce a reference to the current function, much like
> 'this' in a class method. Call it 'self' or 'thisFunc', or whatever ...
> What might this be good for ?
> For implementing recursion in a lambda function.
> Writing in functional style, one creates many functions, and looking for
> reasonable names for these functions becomes unnecessarily painful.

I think it is not the naming that is painful. (I am not aware of
functional languages that have a special identifier for the current
anonymous function.)

What makes writing short named functions inconvenient is lack of this:
http://d.puremagic.com/issues/show_bug.cgi?id=7176



More information about the Digitalmars-d mailing list