doubly-lazy variadics?

Bruno Medeiros brunodomedeiros+spam at
Tue Sep 5 08:35:25 PDT 2006

Walter Bright wrote:
> Don Clugston wrote:
>> I noticed that DMD 0.166 accepts
>> void func(lazy int delegate()[] ...)
>> {
>> }
>> It's not documented -- what does it mean?
> What it means is an array literal is created out of the arguments, which 
> is then wrapped in a delegate.
> That cannot work until array literals are implemented.

Hum, that's odd, I was expecting that the "int delegate()" part would be 
lazy, not the "int delegate()[]" .
Such that an "func(lazy int[] ...)" would do what currently is done with 
this special-case:
"If the variadic parameter is an array of delegates with no parameters.
   void foo(int delegate()[] dgs ...);
Then each of the arguments whose type does not match that of the 
delegate is converted to a delegate"
This special-case, besides being a bit inconsistent(it's a special case! 
:p ), may also be a bit error prone, such as when a given non-delegate 
argument is converted to a delegate under those rules, but an error 
should have occurred instead (because the programmer made an error of 

Oh, and there's an code typo in that section, namely:
   int delegate[] dg;
   foo(1, 3+x, dg, cast(int delegate[])null);

Bruno Medeiros - MSc in CS/E student

More information about the Digitalmars-d mailing list