define should be the keyword for manifest constants

Christopher Wright dhasenan at gmail.com
Thu Dec 13 11:12:12 PST 2007


Steven Schveighoffer wrote:
> Seriously.  Are we too concerned about stigmas to not use the absolute best 
> word for defining a constant?  Even in the description of a manifest 
> constant, it will be something like:
> 
> to *define* a manifest constant, use enum
> 
> If you use *define* you don't even need an explanation!
> 
> If you are concerned about people not liking define because it *looks* too 
> much like C's #define, then lets also drop goto (because C's is just too 
> error prone), class (because there are slicing problems in C++, and we don't 
> want people to think they still exist in D), struct (because C++'s is just 
> like class, so people will think D structs and classes are the same), etc.

Instead of goto, let's use comefrom:

foreach (a; collection) {
    if (a.someproperty) {
       found:
    }
}
throw new Exception("didn't find it!");
comefrom found;


Instead of class, caste.
Instead of struct, skel (short for skeleton).

'new' becomes 'makemea':
auto sandwich = makemea Sandwich;


> If you are concerned about adding a new keyword, please, all coders who have 
> used the symbol define, please respond to this thread, and we'll send you a 
> handy script that will update your code to use another keyword of your 
> choice.  Only $6.95 shipping and handling.

Replacing variables and types that collide with keywords using ANOTHER 
keyword? That's just begging the question!



More information about the Digitalmars-d mailing list