Recursive typedef

Markus Dangl danglm at in.tum.de
Thu Oct 5 10:36:43 PDT 2006


It works easily when i use classes (just as a workaround):

interface ParseFn
{
     ParseFn opCall(char[]);
}

class Example : ParseFn
{
     ParseFn opCall(char[] s)
     {
         if (s == "")
             return null;
         else
             return this;
     }
}

int main(char[][] args)
{
     ParseFn parser = new Example();
     while (parser !is null)
     {
         char[] s;
         s = din.readLine();
         parser = parser(s);
     }

     return 0;
}



More information about the Digitalmars-d-learn mailing list