Can a member function return a delegate to itself?

Manfred Nowak svv1999 at hotmail.com
Wed May 23 15:01:58 PDT 2007


Steve Teale wrote

> Something like:
>     void delegate(int) sum(int n) 
>               { a += n; return cast(void delegate(int)) &this.sum; }

might work with an auxiliary type definition `Th':

import std.stdio;
typedef T delegate() Th;
typedef Th delegate() T;
T g, h;
T f(){
  writefln( "returning own type");
  return g;
}
void main(){
  h= f();
}

-manfred



More information about the Digitalmars-d mailing list