auto storage class - infer or RAII?

Walter Bright newshound at digitalmars.com
Sun Nov 12 03:16:49 PST 2006


Bill Baxter wrote:
> Additionally I keep getting bitten by things like
>     int i;
>     for (i=1; i<10; i++) {
>     }
>     ...
>     foreach(i,elem; elements) {
>        if (...) break;
>     }
>     writefln("last i was", i)
> 
> Which using 'foreach-is-like-for' mentality seems perfectly natural but 
> causes the compiler to complain.

I know it's a little different, but it's so convenient. Also, the 
no-shadowing rule helps flush out errors at compile time before one gets 
bitten.



More information about the Digitalmars-d mailing list