doubly-lazy variadics?

Russ Lewis spamhole-2001-07-16 at deming-os.org
Fri Sep 1 09:57:21 PDT 2006


Don Clugston wrote:
> I noticed that DMD 0.166 accepts
> 
> void func(lazy int delegate()[] ...)
> {
> }
> 
> It's not documented -- what does it mean?

I would assume that it takes an expression which evaluates to an array 
of int() delegates, and it turns the expression into a delegate.

<untestedCode>
   void func(lazy int delegate()[] dg_array_lazy) {
     foreach(int delegate() dg; dg_array_lazy())
       dg();
   }

   void bar() {
     int delegate()[] array;

     array ~= delegate int() { return 1; }
     array ~= delegate int() { return 2; }
     func(array);
   }
</untestedCode>



More information about the Digitalmars-d mailing list