PhobosWatch: manifest => enum

Walter Bright newshound1 at digitalmars.com
Sat Dec 29 15:40:05 PST 2007


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.



More information about the Digitalmars-d mailing list