Private enum members + Descent

Lars T. Kyllingstad public at kyllingen.NOSPAMnet
Mon Oct 26 03:07:26 PDT 2009


Yigal Chripun wrote:
> personally I'd like to see D enums replaced by Java style enums which 
> make more sense to me. D enums are even worse than C enums since you can 
> write:
> enum foo = "text";
> 
> which to me looks very similar to:
> auto cat = new Dog;


I agree that enum is a horrible keyword to use for declaring manifest 
constants. In my opinion the D developers are sometimes a bit too afraid 
of introducing new keywords, and this is one of the consequences.

Personally, I think this would be a better scheme:

     const: manifest constants, no storage (like const in D1, enum in D2)
  readonly: used for a read-only view of mutable data (like const in D2)
immutable: truly immutable data (like now)

-Lars



More information about the Digitalmars-d mailing list