Const sucks

Bruno Medeiros brunodomedeiros+spam at com.gmail
Mon Sep 10 16:45:10 PDT 2007


Walter Bright wrote:
> Const, final, invariant, head const, tail const, it's grown into a 
> monster. It tries to cover all the bases, but in doing so is simply not 
> understandable.
> 

Took you guys a while to figure that out... -_-'

> 1) final (i.e. 'head const') is not necessary for a, b or c. final is a 
> local thing, and not strictly necessary.
> 

Then, there will no longer be a final "storage class" for var declarations?

> 2) tail const can be handled in other ways, read on
> 
[...]
> 
> o  tail const of a struct would have to be done by making the struct a 
> template:
> 
>   struct S(T) { T member; }
>   S!(int)   // tail mutable
>   S!(const(int)) // tail const
> 
> o  one can construct a template to generically produce tail const or 
> tail invariant versions of a type.
> 

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*.


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



More information about the Digitalmars-d mailing list