Const foreach

Simen kjaeraas simen.kjaras at gmail.com
Mon Nov 22 07:39:30 PST 2010


Pelle Månsson <pelle.mansson at gmail.com> wrote:

>> 'auto' is not a placeholder for a type, but the default storage class.
>> IOW, 'int n;' == 'auto int n;'. This does however not compile,
>> complaining that it has no effect.
>>
>> Specifying just the storage class signals the compiler to use type
>> inference. Try it:
>>
>> const x = 4;
>> immutable y = 4;
>>
>
> I'm not sure you are correct:
>
>      const static auto x = 4;

I don't see how this contradicts anything I've said. You can safely
remove auto from that statement, and the type will be inferred to the
same. The fact that it compiles is a compiler bug, if we take the
error message in the 'auto int x;' example to be representative.

-- 
Simen


More information about the Digitalmars-d-learn mailing list