PhobosWatch: manifest => enum
Bruno Medeiros
brunodomedeiros+spam at com.gmail
Sat Jan 5 08:59:25 PST 2008
Walter Bright wrote:
> Jérôme M. Berger wrote:
>> Basically, "auto" should drop the tail-most "const" if the language
>> allows such types to exist and keep the "const" when it can't be
>> dropped, e.g:
>> - "const int" => "int";
>> - "const (T*)" => "(const (T))*" (if such is allowed);
>> - "const (MyClass)" => "const (MyClass)" (since the tailmost type
>> is actually the hidden reference type).
>
> I really did try to figure out how to make that work, but it just
> doesn't. Let's say we make a struct:
>
> struct MyInt
> {
> int x;
> ... and appropriate operator overloading ...
> }
>
> to make our own custom implementation of ints. What do we do with:
>
> const MyInt m = 3;
> auto n = m;
>
> Does n get const or not? If it is, now it is behaving differently from
> other types, and so is not a plug-in replacement. If it does not, what
> happens if MyInt has a pointer member? Suddenly, the const gets stripped
> from the pointer, and there is no const-correctness.
That is a valid problem. But it is a problem with the const semantics
and the type inference functionality. It is not a problem with the
declaration of manifest constants, so please don't introduce a problem
in one place (making 'enum' not mean "enumeration" anymore, among other
things) to fix a problem that has its roots in another place ('auto')... :X
--
Bruno Medeiros - MSc in CS/E student
http://www.prowiki.org/wiki4d/wiki.cgi?BrunoMedeiros#D
More information about the Digitalmars-d
mailing list