On 07/19/2012 04:54 AM, Mehrdad wrote:
On Tuesday, 17 July 2012 at 16:56:17 UTC, 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.

Recursive lambdas? o.O

Instead of changing the language, I'd say your situation merits using
the Y combinator... maybe define Y(f) to be (g => g(g))(g => f(x =>
g(g)(x)))
then if you need to define factorial, just say...
fact = Y(fact => n => n > 0 ? n * fact(n - 1) : 1);




- D does/can not have full type inference, because the type system with
  templates is Turing complete.

- There is no way this is going to type check even with explicit type
  annotations, because there are no recursive function types.

- Allocation of closures for control flow is not going to work
  efficiently with the current GC.

- D actually has named functions, there is no need to use the anonymous
  lambda based y combinator to make up for the lack of them.

Reply via email to