Calling anonymous delegate recursively ?

Andrej Mitrovic andrej.mitrovich at
Sat Jan 8 09:40:43 PST 2011

As a workaround you can do this for now:

import std.stdio;

enum deleg = returnFib();
ulong delegate(ulong m) returnFib()
    return (ulong m)
        if(m < 2)
            return m;
        return deleg(m-1)+deleg(m-2);

void main()

Otherwise I'd really like the ability for a lambda to call itself.
Perhaps a feature request is in order.

More information about the Digitalmars-d-learn mailing list