[Oberon] Initial value of variables, where specified?

Chris Burrows chris at cfbsoftware.com
Wed Feb 12 22:37:53 CET 2020

I have always had difficulty understanding this question of initialisation.
I don't see why initialising memory areas to zero is any better than no
initialisation. It might lead to more predictable behaviour but not
necessarily correct behaviour. In the worst case it can mask the fact that a
variable has not been sensibly initialised.

e.g. Zero might be OK for initialising strings but how can you tell if an
integer that is zero has been correctly initialised? 

e.g. if a variable represents a temperature in Fahrenheit does it make sense
to initialise it to zero?

e.g. Would it be better if REAL variables were initialised to NaN?

e.g. Would it be better to initialise INTEGER values to -MAXINT?
Consequential nonsense values in calculation results might help to flush out
uninitialised variables earlier ;-)

Unless my memory fails me, the CDC6000 version of Pascal that I used in the
1970s initialised variables to a specific value which represented
'undefined'. Any attempt to reference such a variable resulted in a
(hardware?) exception. That was very useful. (Data in the CDC system was
based on a word length of 60 bits).

It is good defensive-programming practice for an Oberon programmer to ensure
that all variables they are using are explicitly initialised correctly for
the specific application that they are implementing. They should not rely on
the underlying system to initialise for them - particularly if they are
intending their application to run on different systems.

Chris Burrows
CFB Software

> -----Original Message-----
> From: Oberon [mailto:oberon-bounces at lists.inf.ethz.ch] On Behalf Of
> rochus.keller at bluewin.ch
> Sent: Thursday, 13 February 2020 7:09 AM
> To: oberon at lists.inf.ethz.ch
> Subject: Re: [Oberon] Initial value of variables, where specified?
> @ Joerg Straube
> Ok, I see, thanks. I will modify my code generator accordingly.
> @ Chris Burrows
> Thank you for the hint. I leave it up to the designer of the language
> what should be initialized automatically. Since Oberon is garbage
> collected, at least the pointers will likely be initialized with NIL.
> I was just a bit surprised that the Oberon system seems to rely on
> initializations, although these are not specified in the Language
> Report.
> Best
> R.
> --
> Oberon at lists.inf.ethz.ch mailing list for ETH Oberon and related
> systems https://lists.inf.ethz.ch/mailman/listinfo/oberon

More information about the Oberon mailing list