Auto keyword with const variable
Artur Skawina
art.08.09 at gmail.com
Wed Jul 24 03:37:23 PDT 2013
On 07/24/13 12:09, monarch_dodra wrote:
> Keeping it to "same type, 100% of the time" seems like the best.
No, it's a design bug. The head qualifier(s) should always be stripped
when copying objects. Stripping is always fine (ie safe), not doing it
just creates other problems, like the one in OP, or unnecessary template
bloat. The IFTI special cases that are already there are just handling
one of the symptoms.
As you can always declare something as 'immutable' or 'const', instead
of 'auto', the default would have to be head-mutable [1]. Ie, this would
then work:
const int a;
immutable b = a; // immutable int
const c = a; // const int
auto d = a; // int
Right now, you have to do `auto d = cast()a;` or use the Unqual hack...
artur
[1] If D had a `var` qualifier, then defaulting to 'const' might be
better. But it doesn't.
More information about the Digitalmars-d-learn
mailing list