Code behaves incorrectly if it is compiled in std.functional

ketmar via Digitalmars-d digitalmars-d at puremagic.com
Mon Jun 8 06:17:00 PDT 2015


On Mon, 08 Jun 2015 13:47:09 +0200, Timon Gehr wrote:

> On 06/08/2015 11:33 AM, ketmar wrote:
>> On Mon, 08 Jun 2015 09:27:34 +0000, Marc Schütz wrote:
>>
>>>> ergo, `auto` is not a storage class, but type placeholder.
>>>
>>> No.
>>
>> and it's not a storage class too. `foreach (auto i; 0..42)` doesn't
>> work,
>> white `foreach (immutable i; 0..42)` works ok.
>>
>>
> foreach(static i;0..42) doesn't work either, and 'static' is a storage
> class.
> 
> 'immutable' is a type constructor besides being a storage class.
> 
> The attributes allowed in `foreach' are those that are considered to
> make sense, and they are specified in the grammar:
> http://dlang.org/statement.html#ForeachTypeAttributes
> 
> Furthermore, both of those declarations are valid:
> 
> static i = 2;
> immutable j = 3;
> 
> What is important is that the type was left out, not that it was
> replaced by 'auto'.

i tried to explain to some people why `foreach (i; 0..42)` doesn't reuse 
previously declared `i` and failed. it doesn't look like variable 
declaration at all, 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`? now i'm REALLY 
puzzled about what "default storage class" means at all. seems that it's 
"random storage class that means anything /dev/urandom returns".
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20150608/2ea1b2d2/attachment.sig>


More information about the Digitalmars-d mailing list