[Oberon] *****SPAM***** Re: *****SPAM***** Re: Oberon-2 type bound procedure scope

werner.heiz at gmail.com werner.heiz at gmail.com
Tue Dec 12 22:45:50 CET 2023


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.

Werner Heiz

-----Ursprüngliche Nachricht-----
Von: Oberon <oberon-bounces at lists.inf.ethz.ch> Im Auftrag von August
Karlstrom
Gesendet: Mittwoch, 13. Dezember 2023 10:27
An: oberon at lists.inf.ethz.ch
Betreff: Re: [Oberon] *****SPAM***** Re: *****SPAM***** Re: Oberon-2 type
bound procedure scope

On 2023-12-12 10:02, Diego Sardina wrote:
[...]
>...however since then only strictly local and strictly global objects are
available to a procedure.

Indeed, this has been confirmed by Niklaus Wirth. For instance I asked him
about the validity of the following procedure:

	PROCEDURE P;
	   TYPE T = INTEGER;

	   PROCEDURE Q(x: T): T;
	   RETURN 0
	   END Q;
	END P;

His reply was "You are right. Your procedure Q should be diagnosed in
error."

As mentioned before, the Project Oberon 2013 compiler does not fully conform
to the language report. I don't know if it's due to lack of time to make the
changes to the compiler or if he want's the implementation to be different.


August
--
Oberon at lists.inf.ethz.ch mailing list for ETH Oberon and related systems
https://lists.inf.ethz.ch/mailman/listinfo/oberon



More information about the Oberon mailing list