const?? When and why? This is ugly!

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Fri Mar 6 19:58:45 PST 2009


Burton Radons wrote:
> Andrei Alexandrescu Wrote:
>> The problem is you set up artificially constrained rules, i.e.
>> "without using templates". You can't use the same struct to store
>> mutable types and non-mutable types mixed with always-mutable
>> types, and for good reasons. No type system will allow 100% of the
>> correct programs to run. Why the fuss. Use a gorram template and
>> call it a day.
> 
> Ah, so you don't have a solution.

I do have a solution, the problem is sometimes no amount of convincing 
will do any good. Arguments focusing on niche cases can be formulated 
against every single restriction of a type system. Const and immutable 
are supposed to express realities about data. Sometimes said realities 
undergo dialectics that are difficult to express. The system is not 
perfect, and cannot be made perfect within the constraints at hand (e.g. 
without putting undue complexity on the programmer). If you're bent from 
the get-go against const and immutable, there is no good scenario that 
is good enough, no bad scenario that's infrequent and avoidable enough, 
and no way to purport a gainful dialog.

Andrei



More information about the Digitalmars-d mailing list