PhobosWatch: manifest => enum

Walter Bright newshound1 at digitalmars.com
Fri Dec 28 03:15:08 PST 2007


Jérôme M. Berger wrote:
> Walter Bright wrote:
>> Jérôme M. Berger wrote:
>>>     :(
>> Yeah, I figure I'll get fricasseed over that one. The most compelling
>> argument is that we already have 3 ways to declare a constant, adding a
>> fourth gets very difficult to justify. As opposed to a minor extension
>> to enums.
> 
> 	This is an artificial distinction: you *are* adding a fourth way to
> declare a constant,

Not really, just loosened up the restrictions on enum. The 
implementation code is actually simpler <g>.


> the only question is what syntax to use: either
> a counter-intuitive extension to enums or a new keyword (or a minor
> extension to the alias keyword as was suggested by somebody).

I found the "use an alias when declaring one constant" and "use an enum 
when declaring more than one constant" to be difficult to justify. It's 
like saying arrays with only one element should not be allowed.


> 	BTW, I think it was Janice who suggested that the compiler should
> know whether a constant needs to be manifest or not (depending on
> whether its address is taken somewhere). This would remove the need
> for a way to distinguish manifest constants explicitly. Any thoughts
> on that?

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.



More information about the Digitalmars-d mailing list