Manifest constants - why not 'alias' ?

Christopher Wright dhasenan at gmail.com
Fri Dec 7 16:17:33 PST 2007


Janice Caron wrote:
> On 12/7/07, Leandro Lucarella <llucax at gmail.com> wrote:
>> That's the worst reason ever! There are so many things we already use that
>> sucks...
> 
> Yep, I agree with everyone. Especially with the above comment. I will
> certainly /stop/ writing enum { x=3 } if a more intuitive way comes
> along.
> 
> So there you have it, Walter: Unanimous support on this newsgroup
> (...is that unprecedented?...) for NOT using enum as a storage class
> to define compile-time constants.

The objections are not quite unanimous. I don't see a problem with it.

I do, however, have a problem with using 'final'. It just doesn't have 
any indication of being constant in my mind, since I've used Java and 
been able to assign to final variables time out of mind. Using enum has 
the benefit that nobody has ever been able to assign to an enum value.

Also, enum has the benefit of allowing groupings of constants. 
Potentially, at least, and certainly if you allow for casts, though 
that's cheating and ugly.



More information about the Digitalmars-d mailing list