Extended Type Design.

Andrei Alexandrescu (See Website For Email) SeeWebsiteForEmail at erdani.org
Fri Mar 16 11:28:21 PDT 2007


Benji Smith wrote:
> Andrei Alexandrescu (See Website For Email) wrote:
>> We've shoved keywords like "readonly" and "view" for a while, and they 
>> just added more confusion than cleared, at a high cost. If (as I 
>> suspect) super const appears relatively infrequently, it might be fine 
>> to just encode it as the mildly verbose "super const". In fact, it's 
>> shorter than "keepyourgrubbyhandsoff". :o)
>>
>> Andrei
> 
> Really? I'd think super const would be used all the time. Anywhere a 
> class has some invariant field, it'll probably be expressed as super 
> const (if I'm understanding correctly that super const is the equivalent 
> of #define constants in C++ or static final constants in Java).

No. super const deals with pointers and transitivity. Final deals with 
non-rebindable symbols. I'd be hard pressed to think of many examples 
where class members are transitively immutable.

> Let me join the ranks of those who hate both versions of the new syntax. 
>  const! looks either like a template or like "not const". You guys may 
> think you're saving a keyword, and that might be technically correct 
> from the perspective of the parser.

The parser has zilch to do with it.

> But, for the perspective of the D 
> developer, it still looks like you've introduced a new keyword, but it's 
> a keyword that's A) nearly identical to another keyword, and B) contains 
> a symbol. Ugh. I really. Really. Really. Hate it.

Can't help. For any given feature, there will be people who hate it. 
Usually they are also the most vocal :o).

> Using "super const" is also annoying because all of the other storage 
> classes use a single keyword. Now we've got this weird case that uses 
> two keywords. And the word "super" is now overloaded in two completely 
> unrelated concepts.

So what? Don't we use words in natural language that are polysemous too? 
As long as the context makes it unambiguous, great.

> (By the way, I don't like "static if" either. I think the right choice 
> would have been #if, #foreach, etc. And I think C++ made a mistake by 
> defining "long long" and "double double" types as well. Presumably, that 
> saved some keywords, but we'd all have been better off if the types were 
> defined as int8, int16, int32, int64, float32, float64, etc).

You're making my point exactly. I love static if, and don't like #if. 
Again: for each feature, there will be people who like it and hate it :o).

> I vote for "readonly" and "const". Anything else seems like a mistake.

Which is which? How would you have people distinguish them without 
running to the manual? How would you explain C++ immigrants that const 
is actually readonly, and there is a const, but that const means 
something else than their const?


Andrei



More information about the Digitalmars-d mailing list