PhobosWatch: manifest => enum

Walter Bright newshound1 at digitalmars.com
Fri Dec 28 10:32:56 PST 2007


Bruce Adams wrote:
> On Fri, 28 Dec 2007 11:15:08 -0000, Walter Bright 
> <newshound1 at digitalmars.com> wrote:
>> The reason this won't work is because:
>>     const int x = 3;
>> will type x as const(int), not int. There needs to be a way to declare 
>> a constant of type int.
> 
> This doesn't make sense to me. Why would you ever want a constant that 
> was not const?
> and particularly a manifest constant? The only way you can change a 
> manifest constant is
> by changing the source code. Things don't come much more constant than 
> that.
>  The only conceivable reason I can think of is that there is a bug or 
> misfeature somewhere
> where something needs to be type equal when in fact it needs only to be 
> type compatible.

The issue stems from trying to decide if const(T) is always, or only 
sometimes, a different type than T. It must be a different type if T is 
a struct or class type. Pulling on the string of trying to make the type 
system completely consistent (so that generic code will work), and on 
the idea that a struct can be used to wrap any type, and one is drawn 
inevitably to conclude that const(T) is always a different type from T.



More information about the Digitalmars-d mailing list