[M3devel] [M3commit] CVS Update: cm3

Tony Hosking hosking at cs.purdue.edu
Tue Jul 6 17:45:21 CEST 2010


I guess I just don't see the difference between writing:

:= 0

or

:= 1234567

or

:= -1

other than perhaps efficiency.

In which case, excepting that you have a *known* initial value, writing:

: INTEGER

is no less expressive.

On 6 Jul 2010, at 11:11, Rodney M. Bates wrote:

> 
> 
> Mika Nystrom wrote:
>> As I've said before,
>> When I write:
>> VAR   a : INTEGER;
>> BEGIN
>>  ...
>>  .... a := ..    ...
>>  ...
>> END
>> that means I am putting you, the reader, on notice that I have no
>> particularly meaningful idea of what a's initial value is.
>> If I were to write VAR   a := 0;
>> BEGIN
>> ...
>> END
>> I would mislead you into thinking that 0 is a somehow important
>> initial value.  Which it's not.  It's just garbage, and it better
>> not show up in the computation!
> 
> I often write an initialization in a variable declaration that I
> fully expect will be overwritten before it is used, assuming I
> don't make a mistake elsewhere.  I do this probably more often
> in field declarations of record and object types than in variables.
> 
> I do it because it makes bugs more likely to be repeatable.
> This is at the cost that it may occasionally make a bug go
> unnoticed altogether because the initial value happens to
> suppress an obvious symptom.
> 
> *But*, if it's code I wrote in the last ten years, or
> maybe fifteen, such initializations always have (* Paranoid. *)
> or (* Defensive. *) or a similar comment, for exactly Mika's
> reason.  It tells a reader that this value is intended not be
> algorithmically significant.
> 
> I suppose one could assume that an implementation of Modula-3
> would initialize things consistently, but that relies on
> something that is not a rule of the language.  Moreover, it
> is very likely not true for a type where all bit patterns
> represent members of the type.
> 
> Sometimes I try to pick a really weird value, just so
> it will be more conspicuous and more likely to trigger
> a symptom, if it ever gets mistakenly used.  This also helps
> in a debugger just to see if a real algorithmic initialization
> has ever been reached.
> 
> For many types, I often reserve a distinct value to mean "unknown"
> or "meaningless", for some reason or other.  Sometimes I even
> have more than one such special value.
> 
> 
>> Programs are mainly meant to be read by humans, not computers.
>>     Mika
>> Jay K writes:
>>> --_d2468f3b-9666-4291-98b5-5414421f54d9_
>>> Content-Type: text/plain; charset="iso-8859-1"
>>> Content-Transfer-Encoding: quoted-printable
>>> 
>>> 
>>> We are going in circles.




More information about the M3devel mailing list