[Oberon] Oberon-2 type bound procedure scope
Diego Sardina
dsar at eml.cc
Sun Dec 10 16:29:36 CET 2023
On Sun, Dec 10, 2023, at 14:17, August Karlstrom wrote:
> On 2023-12-10 11:19, Diego Sardina wrote:
>
> 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.
>
PROCEDURE Q; BEGIN Q; END Q; hasn't an empty scope, it contains Q.
Before I wrote the definition in Declarations and scope rules because in my interpretation it also allows for a recursive definition/calling, that means that the identifier is already available within the definition.
TYPE T = RECORD t : T END;
MODULE M; IMPORT M; END M.
PROCEDURE P; BEGIN P END P;
Because of this indeed in Oberon-2 report there are these two statements: "A structured type cannot contain itself." and "A module must not import itself.", the problem is solved for these two (Oberon uses pointers to define type recursively, while a module that import itself is more an headache than something useful).
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.
Of course the report had to give an explicit meaning to PROCEDURE P; BEGIN P; END P; and "The use of the procedure identifier in a call within its declaration implies recursive activation of the procedure." explains what happens in that case.
This is my interpretation :-)
--
Diego Sardina
More information about the Oberon
mailing list