[M3devel] [M3commit] CVS Update: cm3

hendrik at topoi.pooq.com hendrik at topoi.pooq.com
Tue Jul 6 19:02:28 CEST 2010


On Tue, Jul 06, 2010 at 06:22:50AM +0000, Jay K wrote:
> 
> Programmers are notorious for making mistakes.
> 
> 
> When you write VAR a:INTEGER;
> you make the human proofreading your code have to work much harder
> to do the data/control flow analysis to make sure you didn't
> use the uninitialized value.
> 
> 
> Using the a := 0 value might still be "wrong", but is it at least consistent
> and the penalty for getting it wrong is generally less severe.
> 
> Now, I don't want there to be a bug either way, but I feel that a consistent 0 is much "safer"
> than uninitialized. Either is typesafe, sure, but type safe is just the bare minimum expectation
> for my code. It must not only be type safe, but act correctly.
> 
> Again, compiler isn't generally a program proofer, but the little it can do, let it do.

Agree with letting the compiler find flaws by flow analysis and 
report them, if it can.

But explicitly initializing it so zero so that (a) the ocmpiler won't 
notice it's really uninitilized, and (b) it's going to have less of a 
penalty for getting it wrong?  I disagree with this.  If there's a bug 
in my program I want to find it so I can fix it.  I don't want it 
masked by an arbitrary but innocuous initial value.

Here's where letting the ocmpiler initialize undefined integer 
variables to something like 1683002888 might actually contribute to 
debugging, especially if it chooses this consistently so you can rerun 
the program reliable while you close in on the error.

But for the programmer to write

  VAR x := 1683002888;

would likely confuse the human reader, who would spend ages pondering 
why *that* value.

- hendrik



More information about the M3devel mailing list