Manifest constants (was const again)

Bill Baxter dnewsgroup at billbaxter.com
Fri Dec 7 14:06:17 PST 2007


Oskar Linde wrote:
> Walter Bright wrote:
>> mandel wrote:
>>> I think enums shouldn't be misused for
>>> compile time constants.
>>
>> But they already are used that way.
> 
> But that is hardly what they are designed for. Like C++ TMP, it is 
> discovered rather than designed. D can do much better.
> 
> Like others, I propose that manifest constants use the alias keyword. 
> Alias is perfect for this. Since they don't occupy storage, they could 
> thus also be polysemous values in the future.
> 
> alias str = "str";
> 
> could mean that
> 
> foo(str)
> 
> is equivalent to
> 
> foo("str")
> 
> Something that typed constants could not handle.
> 

I found it amusing that Walter's counter to this was that it would be 
"confusing" to have both alias X Y and alias Y=X.

This from the guy who was telling us last week that  const int foo() 
really isn't confusing once you get used to it.

I'd say the same about alias Y=X :-)

--bb



More information about the Digitalmars-d mailing list