Code behaves incorrectly if it is compiled in std.functional

ketmar via Digitalmars-d digitalmars-d at puremagic.com
Fri Jun 5 23:12:22 PDT 2015


On Fri, 05 Jun 2015 20:36:19 +0000, Mafi wrote:

> On Friday, 5 June 2015 at 10:56:36 UTC, ketmar wrote:
> 
> 
>> p.s. if "auto" is a storage class, the following code should be
>> accepted (while it isn't):
>>
>>   int foo () { return 42; }
>>
>>   void main () {
>>     auto auto i = foo();
>>   }
>>
>> as it's logically "an auto-typed var with "auto" storage class".
> 
> Here lies your mistake. There is no such thing as "auto"-typed (leaving
> aside function signatures, which might be special-cased and are
> different beast altogether). Auto is not a type. auto* or auto[] aren't
> valied either. Auto is just a storage class, no more, no less. You use
> it if the grammar needs a storage class but you don't want to give
> special attributes to the variable (like const or static). To make a
> declaration with inferred type you need at least one storage class. To
> make it work with "normal" variables you use "auto".

p.s. even more samples: `foreach (auto n; 0..10)`. this doesn't work at 
all. why? `foreach (immutable n; 0..10)` works perfectly. so `auto` 
clearly is not a "storage class", as it is forbidden where storage 
classes are allowed.
-------------- 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/20150606/0d798600/attachment.sig>


More information about the Digitalmars-d mailing list