const question/suggestion

Craig Black cblack at ara.com
Mon Jun 18 08:30:27 PDT 2007


OK, I think I'm starting to grasp the subtle differences between const, 
final, and invariant.  It seems to me that to have three keywords is 
unnecessary.  Perhaps const and final could be merged into one?

>From my understanding, the only difference between const and final is that 
local final fields can be initialized in a constructor, right?  Couldn't 
that just be the default behavior of a local const field?  Then we could get 
rid of final and have only two keywords.  Or am I missing something?  IMO, 
two keywords is way less confusing than three.

Another question.  Since invariant data should always be invariant, does it 
make sense to be able to cast non-invariant data to invariant?  The compiler 
will think that it is invariant when it isn't.

-Craig 





More information about the Digitalmars-d-announce mailing list