[M3devel] [M3commit] CVS Update: cm3

Coleburn, Randy rcolebur at SCIRES.COM
Wed Jul 7 00:19:45 CEST 2010


I agree also.
Let's not change the language here, and let's not change the compiler's behavior to no longer match the language.

I don't have a problem with selectively turning on a warning level at compile time for compiler to warn me that I might be using a variable before it is initialized, but I don't want compiler choosing to initialize it for me.

--Randy

-----Original Message-----
From: Tony Hosking [mailto:hosking at cs.purdue.edu] 
Sent: Tuesday, July 06, 2010 1:00 PM
To: hendrik at topoi.pooq.com
Cc: m3devel at elegosoft.com
Subject: Re: [M3devel] [M3commit] CVS Update: cm3

I agree.

If Modula-3 was being designed today it would impose the same ban on uninitialized use of variables that Java does.
We have a language that does not impose that ban, but instead assures that every ininitialized variable holds a valid value.
I much prefer to see

VAR x: INTEGER

 as an *explicit* marker that the variable holds an indeterminate but valid value.

Seeing

VAR x := 0

implies to me that there is something especially significant about the initial value 0.


On 6 Jul 2010, at 12:53, hendrik at topoi.pooq.com wrote:

> On Tue, Jul 06, 2010 at 10:05:43AM +0000, Jay K wrote:
>> 
>>> used it should be a giant red flag to the reader that the variable x is
>>> going to be initialized with a value that the programmer doesn't know
>>> at the time of declaration. What on earth do you gain from x := 0?
>>> A "little correctness"?
>> 
>> You are making the code more expensive to maintain, by making
>> it harder for a human to analyze. For the benefit of microoptimization.
> 
> Microoptimisation as a purpose?  Didn't he just explain that
>   VAR x : INTEGER;
> is intended to signal to the *reader* that the initial value is 
> irrelevant?  The fact that a naive compiler might compile it slightly 
> more efficiently is a side effect, not a purpose.  If he were interested 
> in microoptimisation, he would better feed it into a flow-analysing 
> compiler, which could even detect when an explicit initialization like
>   VAR x := 0;
> is irrelevant and suppress it.
> 
> It's not *about* optimisation.
> 
> Indeed, they syntactic awkwardness of declaring variables with WITH 
> (to make sure they're initialized where they're declared) is one of 
> the problems of Modula 3, and one of the few places where C did it 
> better.  Granted C, didn't do this at all initially, and took it from 
> Algol 68 in one of C's rounds of standardisation.
> 
> -- hendrik




More information about the M3devel mailing list