Lazy evaluation of function arguments in D

renoX renozyx at gmail.com
Tue May 22 07:18:59 PDT 2012


On Monday, 21 May 2012 at 09:35:30 UTC, Timon Gehr wrote:
>[cut]
> int x;
>
> void f(int){x=anything;}
>
> void main(){ f(x++); }


Yes, and that's why you're supposed to *avoid* the use of global 
variables as much as possible.. Thanks for showing that "lazy" 
has the same issue as global variables..


[cut]
> f(()=>x++) is already short enough.

I would prefer f({x++}) instead but that may be bikeshedding..

renoX



More information about the Digitalmars-d mailing list