Const sucks

Bruno Medeiros brunodomedeiros+spam at com.gmail
Mon Sep 10 18:34:06 PDT 2007


Walter Bright wrote:
> Bruno Medeiros wrote:
>> As Regan asked before, and how would that work for classes? This is a 
>> most fundamental issue that has not been mentioned. Without a way to 
>> declare tail const/invariant, this design, no matter how simpler or 
>> more understandable, is fundamentally *broken*.
> 
> What, exactly, is the use case that needs a solution?

Here's another use case, which is significantly different than the other 
(there should be lots more to be found). Say you have a Person class, 
which has a name, and for whatever reasons you want the name be a String 
class instead of const(char)[]. Then you have:

   class Person {
     const(String) name;
     ...

but now how do you change the name of the Person?...



-- 
Bruno Medeiros - MSc in CS/E student
http://www.prowiki.org/wiki4d/wiki.cgi?BrunoMedeiros#D



More information about the Digitalmars-d mailing list