Recursive Declarations (for functions).

0ffh spam at frankhirsch.net
Fri Aug 24 12:29:08 PDT 2007


Leandro Lucarella wrote:
> http://www.gotw.ca/gotw/057.htm

Ah, I just see in your link that you're also concerned
with "compatibility" and "type safety" issues.
Well, maybe something along these lines will work for you:

alias fptr function() func;
struct fptr
{
   func ptr;
   static fptr create(func ptr)
   {
     fptr fp;
     fp.ptr=ptr;
     return fp;
   }
   fptr opCall()
   {
     return ptr();
   }
}

fptr test()
{
   return fptr.create(&test);
}

void test2()
{
   fptr y=test();
   fptr z=y();
}

Rergards, Frank



More information about the Digitalmars-d mailing list