Extended Type Design.

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


kris wrote:
> Andrei Alexandrescu (See Website For Email) wrote:
>> Benji Smith wrote:
>>
>>> I should also add that, in my opinion, any design where "const" means 
>>> something other than "value resolved at compile time and immutable at 
>>> runtime" would be a mistake.
>>
>>
>> Then how would you call "value that's not mutable through this alias" 
>> in a way that's not going to turn C++ immigrants away?
> 
> 
> there are explicit names for that sort of thing; "immutable", "readonly" 
> , "view" etc.  Reading through the various replies gives the impression 
> that you're concerned about propogating the broken C++ semantics than 
> ensuring D corrects those faults ;)

No, just no gratuitous incompatibilities and misunderstanding. For 
example, "readonly" reminds some of ROM, which is really immutable. 
Then, "view" is too common a word to steal it as a keyword. Finally, 
"immutable" is again ambiguous.

> I think it's worthwhile ensuring D gets it right instead, and I'll 
> happily change all of Tango to reflect that if necessary. Breaking 
> source-code for a keyword that is currently used rarely is not a 
> problem. Incorrect or dubious/confusing semantics are. It may be 
> worthwhile dumping the "const" keyword altogether, to limit confusion.

You know, that might be a good idea.

> BTW, you've also mentioned changing "inout" to "ref" instead? That would 
> probably break more code than a renaming of const; I know both Tango and 
> Mango use inout quite a bit, but I'm happy to change those as necessary. 
> Other people likely feel the same way.

Thanks, that's good to hear. Dropping inout would be one of the harder 
decisions to make.


Andrei



More information about the Digitalmars-d mailing list