[Oberon] Recursion of inner procedures
Diego Sardina
dsar at eml.cc
Tue Dec 12 23:30:23 CET 2023
I'm going to create a new thread since the previous one wasn't really in-topic.
On Tue, Dec 12, 2023, at 20:16, Joerg wrote:
> Not in NW‘s compiler.
> Jörg
>
PO 2013 compiler is based on a 2008 Oberon07 report which had some experimental ideas such as arrays and procedure variables assignment by structure (and other things I don't remember). It wasn't updated since then.
On Tue, Dec 12, 2023, at 22:37, August Karlstrom wrote:
> On 2023-12-12 10:02, Diego Sardina wrote:
>> In both cases not the best definition (what is the definition of
>> environment? what is globally?), however since then only strictly
>> local and strictly global objects are available to a procedure.
>
> I agree that it's not exactly clear exactly what "environment" is but
> that word is no longer used in the language report. A "globally declared
> object" on the other hand must be any object which is not local (to a
> procedure). No ambiguity here that I can see.
Which does not exclude intermediate global objects :-) at first reading it could just be seen as a better definition, a bit less problematic.
On Tue, Dec 12, 2023, at 22:45, werner.heiz at gmail.com wrote:
> Sorry, if I missed something, but if this local/global rule is strictly
> applied without exception, recursive calls like this would not be allowed:
>
> PROCEDURE P; (*P is at scope level 0 = global scope *)
>
> PROCEDURE Q(n: INTEGER); (* Q is at scope level 1 (local to P); n is at
> scope level 2 (local to Q) *)
> BEGIN
> IF n > 0 THEN DEC(n); Q(n) END; (* not allowed if rule strictly
> applied as Q (scope level 1) is called from scope level 2 *)
> END Q;
>
> BEGIN (*P*)
> Q(10);
> END P;
>
> I'm currently working on an Oberon compiler just for fun, and I think this
> should be allowed.
>
Recently I wrote to Wirth about this and he confirmed that inner procedures can call themselves.
How you would implement it? Introducing the procedure identifier in the local scope with the possibility of shadowing it by another local declaration? Of course in a clean way :-)
--
Diego Sardina
More information about the Oberon
mailing list