Intermediate scopes in Oberon-07
I'm experimenting with Peter De Wachter's Oberon RISC Emulator available at https://github.com/pdewacht/oberon-risc-emu using the provided disk image from 2016-08-02. As far as I understand, in the latest version of the Oberon programming language no access to intermediate scopes is allowed. Still the compiler accepts the following module: MODULE M; PROCEDURE P; CONST c = 0; TYPE T = INTEGER; PROCEDURE Q; VAR x: T; BEGIN x := c END Q; END P; END M. Haven't Niklaus Wirth updated the compiler accordingly or doesn't the disk image reflect the latest implementation of PO2013 or am I missing something else here? Regards, August
On Fri, Feb 9, 2018, at 9:53 AM, August Karlstrom wrote:
Haven't Niklaus Wirth updated the compiler accordingly or doesn't the disk image reflect the latest implementation of PO2013 or am I missing something else here?
For what I remember, in the previous Oberon-07 report only access to intermediate variables was disallowed, but you were able to access to other intermediate objects (types, constants and procedures). Let's see the evolution. Oberon: "... the objects declared in the environment of the procedure are also visible in the procedure (with the exception of those objects that have the same name as an object declared locally)." Oberon-07 report (2008): "... the objects declared in the environment of the procedure are also visible in the procedure (with the exception *of variables and* of those objects that have the same name as an object declared locally)." Later it was generalized to all intermediate objects and the whole sentence was simplified in: Oberon-07 report (2013): "...the objects declared globally are also visible in the procedure." Yes, maybe he didn't update PO2013 compiler's implementation. -- Diego Sardina
On 2018-02-09 10:30, Diego Sardina wrote: [...]
Yes, maybe he didn't update PO2013 compiler's implementation.
OK, thanks for the information. If access to all intermediate objects is disallowed, can a procedure signature still reference locally declared types? For instance, is the following module valid: MODULE test; PROCEDURE P; TYPE T = INTEGER; PROCEDURE Q(x: T): T; RETURN 0 END Q; END P; END test. As I understand it, the local scope of Q starts before the list of formal parameters but I may be wrong here. Also, one of the reasons for disallowing all access to intermediate scopes is that it allows the declaration of a procedure to be moved outside or inside another procedure without invalidating the module. If the types in the parameter list references an intermediate scope the procedure is not really "self contained." -- August
On 2018-02-09 11:51, August Karlstrom wrote:
MODULE test;
PROCEDURE P; TYPE T = INTEGER;
PROCEDURE Q(x: T): T; RETURN 0 END Q; END P;
END test.
I have been in contact with Prof. Wirth and he confirms that "procedure Q should be diagnosed in error." Therefore, access to any kind of object from an intermediate scope is not allowed in Oberon-07/16. This holds true even for parameter types as illustrated by the example above. -- August
participants (2)
-
August Karlstrom -
Diego Sardina