documentation and papers about const/invariant

Dee Girl deegirl at noreply.com
Tue May 20 09:23:14 PDT 2008


Bill Baxter Wrote:

> Sean Kelly wrote:
> 
> > This is why I don't like some of the decisions in D 2.0.  Choosing 'enum',
> > for example, to represent manifest constants.  It takes a necessary hack
> > from C (declaring constants as enum values because it's either that or
> > #define and #define stinks) and formalizes it as the Right Way to declare
> > manifest constants.  Personally, I think that anonymous enums shouldn't
> > be allowed at all--formalizing the approach is a disaster.  I guess what
> > I'm saying is that I simply don't accept the argument that D should
> > support C syntax, even bad C syntax, simply in hopes that it will help
> > gain acceptance from the C community.
> 
> Step 7 of the 12 step program for converting C++ to D is "global replace 
> 'typedef' with 'alias'".  It would not be hard to add a step 13: "global 
> replace 'enum' with 'manifest'" or 'constant' or some other word that 
> makes more sense than enum.  So I really don't buy any argument that 
> says "enum" has to stay "enum" for the benefit of C++ folks.
> 
> For whatever reason, back in the day Walter realized that it was no 
> longer appropriate to call D's expanded typedef a typedef and so he gave 
> it a sensible name that matched its expanded role much better.  I'm not 
> sure what's changed, but for some reason today he seems to have the 
> attitude of "eh, a word is a word.  What's it matter what we call it?".
> 
> I have to agree with the pigs in Orwell's Animal farm on this one: "all 
> words are equal, but some words are more equal than others."

Indeed words are important. Especially when language (English) understanding is poor ^_^ But I think enum is fine for new comer. Enumerate some constants in a file, just say enum a = 1, b = "hello", c = 3.14. To me it was always like enum was limited. Why did all have to be integers and why did all have to be a new type? Often you care for the value not type. Why did all enum value be part of a distinct type? I like it there is less restriction. 

About documentation. Maybe somebody here could write article about D const/invariant and put online. People here know very many things. Thank you, Dee Girl




More information about the Digitalmars-d mailing list