[Oberon] Oberon-2 type bound procedure scope
Diego Sardina
dsar at eml.cc
Sun Dec 10 20:43:04 CET 2023
On Sun, Dec 10, 2023, at 17:09, August Karlstrom wrote:
> 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.
>
I remembered that code from a previous topic we had 10 years ago on the astrobe forum:
http://astrobe.com/forum/viewtopic.php?f=4&t=281&sid=f6b91e824d173ac26f817e780df671a0&start=20
Like Chris I thought the procedure identifier is also available in the local scope of the procedure, that makes sense because of the definition in the report (that is similar to that of Modular-3 that also has recursive declarations explicitly, furthermore Oberon-2 explicitly forbids them for structured types and modules).
But after a conversation with Wirth by Chris, it is available because it's in the outer scope, at this point only those procedures in the module scope may be called recursively.
That said "The call of a procedure within its declaration implies recursive activation." is not well defined.
I would accept B for simplicity but that's problematic because in a recursive descent parser Factor(), that is the innermost procedure, calls itself.
Did you ask Wirth about this?
--
Diego Sardina
More information about the Oberon
mailing list