Amusing D facts: typesafe variadic arrays are lazy!

Denis Koroskin 2korden at gmail.com
Tue Oct 13 06:50:50 PDT 2009


On Tue, 13 Oct 2009 17:06:25 +0400, downs <default_357-line at yahoo.de>  
wrote:

> Did you know the following code compiles?
>
>> module test;
>>
>> import std.stdio;
>>
>> void Assert(bool cond, string delegate()[] dgs...) {
>>   debug if (!cond) {
>>     string str;
>>     foreach (dg; dgs) str ~= dg();
>>     throw new Exception(str);
>>   }
>> }
>>
>> void main() {
>>   Assert(false, "O hai thar! ");
>> }
>
>
> It's true! :)

Wow, indeed!



More information about the Digitalmars-d mailing list