[Oberon] Procedure variables and local procedures
Skulski, Wojciech
skulski at pas.rochester.edu
Thu Sep 28 19:06:44 CEST 2017
Andreas:
is the following code correct? If so, can another module import M and call M.proc()? What is the intent, if it is possible?
MODULE M;
TYPE PROC* = PROCEDURE;
VAR proc*: PROC;
PROCEDURE P () : PROC;
VAR p: PROCEDURE;
PROCEDURE Q; BEGIN END Q;
BEGIN p := Q
RETURN p
END P;
END M.
________________________________________
From: Oberon [oberon-bounces at lists.inf.ethz.ch] on behalf of Andreas Pirklbauer [andreas_pirklbauer at yahoo.com]
Sent: Thursday, September 28, 2017 12:57 PM
To: ETH Oberon and related systems
Subject: [Oberon] Procedure variables and local procedures
Addendum: Another way to read the sentence “P must not be declared local to ANOTHER procedure” is that in fact “P may be declared local to the SAME procedure”. This is the case in the example below. Either way, the assignment to procedure variables is not restricted to globally defined procedures.
AP
On 28 Sep 2017, at 18:11, Andreas Pirklbauer <andreas_pirklbauer at yahoo.com<mailto:andreas_pirklbauer at yahoo.com>> wrote:
Note that even though the Oberon language report of Oberon-07 still states that “If a procedure P is assigned to a procedure variable of type T [...]. P must not be declared local to another procedure”, in the current implementation of Oberon-07, this restriction is not actually checked - at least not in the case when the procedure variable to which a local procedure is assigned is itself declared locally in the same scope, as in the following example:
MODULE M;
PROCEDURE P;
VAR p: PROCEDURE;
PROCEDURE Q; BEGIN END Q;
BEGIN p := Q
END P;
END M.
which compiles correctly under Oberon 2013 without an error message.
AP
--------------------------------------------------------------------------
August Karlstrom fusionfile at gmail.com<mailto:fusionfile at gmail.com> Thu Sep 18 12:14:29 CEST 2017
In the latest revision of the Oberon language, access to identifiers in
intermediate scopes is denied. Doesn't this imply that the restriction
that only globally defined procedures can be assigned to procedure
variables, is the unnecessary?
-- August
More information about the Oberon
mailing list