Manifest constants (was const again)

Oskar Linde oskar.lindeREM at OVEgmail.com
Fri Dec 7 12:11:29 PST 2007


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.

-- 
Oskar



More information about the Digitalmars-d mailing list