[Oberon] Initial value of variables, where specified?

rochus.keller at bluewin.ch rochus.keller at bluewin.ch
Wed Feb 12 01:10:09 CET 2020


What value is a variable supposed to have before it is explicitly assigned a value? 

E.g. in MenuViewer.Mod line 205 I found at projectoberon.com there is a call of Viewers.Open(V, X, Y) where V is of type Viewer and NEW(V) is called on line 203. In Viewers.Open V.state is accessed for the first time; there was no explicit assignment to V.state before (at least I didn't see one). Since the code works I assume that V.state is automatically initialized to zero by the generated code.

Where is this behaviour specified? I looked through different language report versions and books but didn't find a clear answer yet. 
Is it the same for all variable types, e.g. also for arrays? If I e.g. declare VAR a: ARRAY10 OF INTEGER, are the elements of a supposed to be zero when the module is loaded (i.e. before the statement sequence is executed)?

Best
R.


More information about the Oberon mailing list