[Oberon] Oberon-2 type bound procedure scope

August Karlstrom fusionfile at gmail.com
Sun Dec 10 17:09:24 CET 2023


On 2023-12-10 16:29, Diego Sardina wrote:
> PROCEDURE Q; BEGIN Q; END Q; hasn't an empty scope, it contains Q.

If Q, as you say, is contained in its local scope (in addition to P:s 
scope) then you wouldn't be able to declare a local object inside Q with 
the same name because

"No identifier may denote more than one object within a given scope."

So with your interpretation this procedure would be invalid:

	PROCEDURE Q;
	   VAR Q: INTEGER;
	END Q

However, it is valid and what happens is that the identifier Q from the 
parent scope is shadowed by the variable Q in the local scope.

> So, procedures are allowed to call themselves, and that doesn't
> depend on the nesting level but because the declaration is already
> introducing the identifier in that scope.

In Oberon-2 there is no ambiguity because all the intermediate scopes 
are searched, so a recursive call will find the procedure identifier in 
the parent scope.


/August


More information about the Oberon mailing list