Re: Delegate returning itself

2014-12-08 Thread Jonathan Marler via Digitalmars-d-learn
On Saturday, 6 December 2014 at 15:46:16 UTC, Adam D. Ruppe wrote: The problem is the recursive *alias* rather than the delegate. Just don't use the alias name inside itself so like alias MyDelegate = void delegate() delegate(); will work. The first void delegate() is the return value of the

Re: Delegate returning itself

2014-12-08 Thread Jonathan Marler via Digitalmars-d-learn
On Monday, 8 December 2014 at 14:08:33 UTC, Jonathan Marler wrote: On Saturday, 6 December 2014 at 15:46:16 UTC, Adam D. Ruppe wrote: The problem is the recursive *alias* rather than the delegate. Just don't use the alias name inside itself so like alias MyDelegate = void delegate()

Re: Delegate returning itself

2014-12-08 Thread via Digitalmars-d-learn
On Monday, 8 December 2014 at 14:31:53 UTC, Jonathan Marler wrote: On Monday, 8 December 2014 at 14:08:33 UTC, Jonathan Marler wrote: On Saturday, 6 December 2014 at 15:46:16 UTC, Adam D. Ruppe wrote: The problem is the recursive *alias* rather than the delegate. Just don't use the alias name

Re: Delegate returning itself

2014-12-08 Thread Jonathan Marler via Digitalmars-d-learn
On Monday, 8 December 2014 at 14:38:37 UTC, Marc Schütz wrote: On Monday, 8 December 2014 at 14:31:53 UTC, Jonathan Marler wrote: On Monday, 8 December 2014 at 14:08:33 UTC, Jonathan Marler wrote: On Saturday, 6 December 2014 at 15:46:16 UTC, Adam D. Ruppe wrote: The problem is the recursive

Re: Delegate returning itself

2014-12-08 Thread Ali Çehreli via Digitalmars-d-learn
On 12/06/2014 07:28 AM, Jonathan Marler wrote: Is there a way to create a delegate that returns itself? Y combinator helps exactly with that: http://rosettacode.org/wiki/Y_combinator#D Copying the code from there: import std.stdio, std.traits, std.algorithm, std.range; auto Y(S, T...)(S

Delegate returning itself

2014-12-06 Thread Jonathan Marler via Digitalmars-d-learn
Is there a way to create a delegate that returns itself? alias MyDelegate delegate() MyDelegate; // OR alias MyDelegate = MyDelegate delegate(); When I compile this I get: Error: alias MyDelegate recursive alias declaration The error makes sense but I still feel like there should be a way to

Re: Delegate returning itself

2014-12-06 Thread Adam D. Ruppe via Digitalmars-d-learn
The problem is the recursive *alias* rather than the delegate. Just don't use the alias name inside itself so like alias MyDelegate = void delegate() delegate(); will work. The first void delegate() is the return value of the MyDelegate type.