[Oberon] Obstacles when programming in RISC Oberon and proposed patches
Richard Hable
informujo at aon.at
Sun May 25 13:34:01 CEST 2014
On 05/24/14 22:13, Michael Schierl wrote:
> 1. Uninitialized local variables
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> When something is allocated on the heap with NEW, all bytes are zeroed
> out (in Kernel.New). Variables declared at the top of the module are
> also zeroed out (in Modules.Load). Only local variables that live on the
> stack are not zeroed out, but stay what they are. It is easy to miss an
> initialization, resulting in a program that "sometimes works". On the
> other hand, it is also easy to patch the compiler to zero out these
> stack areas:
But this would lead to inefficiency and incompatible Oberon programs
relying on automatic initialization of local variables.
I would prefer a solution similar to Java, where the compiler does not
allow reading local variables, if it isn't sure that they have already
been assigned a value. The Oberon compiler could create warnings in
such cases.
Richard
More information about the Oberon
mailing list