Code behaves incorrectly if it is compiled in std.functional

Timon Gehr via Digitalmars-d digitalmars-d at puremagic.com
Mon Jun 8 06:54:23 PDT 2015


On 06/08/2015 03:17 PM, ketmar wrote:
> ...
>
> i tried to explain to some people why `foreach (i; 0..42)` doesn't reuse
> previously declared `i` and failed.

The reason is that it wouldn't make any sense.

> it doesn't look like variable declaration at all,

It looks like a variable declaration because it is a variable 
declaration. It declares the foreach loop variable.

> and there is no way to make it look like variable
> declaration without specifying a type or `const/immutable/etc.`. so
> "default storage class" doesn't make sense in `foreach`?

I didn't make the decision, but it is redundant.




More information about the Digitalmars-d mailing list