[Oberon] Procedure variables and local procedures

August Karlstrom fusionfile at gmail.com
Fri Sep 29 17:59:27 CEST 2017


On 2017-09-29 16:58, chris wrote:
> On Fri, 29 Sep 2017 15:22:57 +0200, Andreas Pirklbauer wrote:
> <https://www.inf.ethz.ch/personal/wirth/CompilerConstruction/CompilerConstruction2.pdf>
>> ("In fact, programming experience has shown that the access of
>> intermediate level variables is bad practice and better be avoided.
>> Implementers must welcome this insight, as it makes the static link
>> superfluous.”)
> 
> What are the good reasons?

Instead of having to look for the declaration of an identifier in each  
nested scope you now know you can find it

	1. among the local variables of the current procedure,
	2. among the formal parameters of the current procedure, or
	3. among the global variables.

This makes the source text easier to follow. In this context I think  
there is one thing that the programming language PHP got right, namely  
if a global variable $x is to be used in a subroutine it must be  
(re)declared among the local variables as

	global $x;

With this approach there are no "unbound" variables in a subroutine.


-- August


More information about the Oberon mailing list