[Oberon] Oberon-2 type bound procedure scope

August Karlstrom fusionfile at gmail.com
Sun Dec 10 14:17:54 CET 2023


On 2023-12-10 11:19, Diego Sardina wrote:
> For me it's still unambiguous.

OK, let's take it one more time from the start. The question is whether 
this is a valid (although meaningless) module in Oberon-07:

	MODULE M;
	
	   PROCEDURE P;
	      PROCEDURE Q;
	      BEGIN
	         Q
	      END Q;
	   END P;
	
	END M.
	
There are three scopes in this module:

	1. the global scope of M
	2. the local scope of P
	3. the local scope of Q.

P is declared in the global scope of M, Q is declared in the local scope 
of P and nothing is declared in the local scope of Q. Without the sentence

"The use of the procedure identifier in a call within its declaration 
implies recursive activation of the procedure."

in the Oberon-07 language report the module would not be valid since in 
Oberon-07 we cannot access intermediate scopes; Q is called in the local 
scope of Q (where nothing is defined) and the global scope has only P so 
no Q in sight.

Now, the quoted sentence above can be read as

A) an exception to the usual scope rules (in which the module is valid) or

B) a rule which doesn't "violate" the scope rules (in which the module 
is invalid) and which implies that only global procedures can call 
themselves.

If I understand you correctly, Diego, you interpret it as A. The third 
possibility is that I'm wrong about "each identifier exists in exactly 
one scope"; can Q exist both in the local scope of P *and* in the local 
scope of Q?

Please, tell me where I'm wrong in my reasoning.

> Did you try that in Project Oberon 2013?

Yes, the module is accepted by the Project Oberon compiler but on the 
other hand this compiler accepts a few other things which is in conflict 
with the language report such as for instance structural equivalence of 
arrays.


/August


More information about the Oberon mailing list