Public outcry -- maybe not?

Paul paul.justtheletterd.anderson at comcast.net
Tue Jul 3 10:23:49 PDT 2007


Jari-Matti Mäkelä Wrote:

> kris wrote:
> 
> > For example, suppose I'm
> > maintaining some code that looks like this:
> > 
> > # int x;
> > # x = 42;
> > 
> > and decide that those ought to be folded together while I'm cleaning up
> > something else? Ouch! Potentially nasty bug
> > 
> > In other words, assigning .init values should be associated with
> > type-declaration only, and not with type-instancing. This is a simple
> > rule to comprehend - one that gravitates toward the principal of least
> > surprise?
> 
> I agree with this too. Those initial values could be placed to a constant.
> Language consistency is more important than avoiding the need for very
> little extra typing.

I agree. The .init value should be tied to the type and not the variable. Initializing the variable to a const/invariant/whatever value and checking against that value is not onerous, IMHO.

Paul



More information about the Digitalmars-d mailing list