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

strohm at airmail.net strohm at airmail.net
Sun Dec 10 15:29:33 CET 2023


	


 
Oberon, like Modula-2 and PASCAL before it, is a nested-scope language.

The disagreement appears to originate with August Karlstrom's statement that "... in the Oberon-07 language report the module would not be valid since in
Oberon-07 we cannot access intermediate scopes."  I do not find verbiage to that effect in the language report, cited below.

In the example at hand, as I read "In addition to its formal parameters and locally declared objects, the objects declared globally are also visible in the procedure." on page 12 of the Oberon-07 report at Microsoft Word - Oberon07.Report.doc (ethz.ch), items declared at module M scope are visible inside Q, as are items declared at procedure M.P scope.

The fully-qualified scope names would be:

   M
   M.P
   M.P.Q

The scope M.P.Q, i.e. recursive procedure Q, is entirely contained in procedure scope M.P.  As such, anything declared in M.P is visible to M.P.Q.  Q, standing alone, is unambiguous, i.e., it can only refer to M.P.Q.  As it is called from within M.P.Q, it is a recursive invocation.

It is important to remember that Wirth et al valued pragmatics as well as pure theory.  When the pure theory and the pragmatics disagree, they would expend the necessary effort to make them agree.

--John R. Strohm



On Sun, 10 Dec 2023 14:17:54 +0100, August Karlstrom <fusionfile at gmail.com> wrote:

On 2023-12-10 11:19, Diego Sardina wrote:
> For me it's still unambiguous.

OK, let's take it one more time from the start. The question is whether
this is a valid (although meaningless) module in Oberon-07:

MODULE M;

   PROCEDURE P;
      PROCEDURE Q;
         BEGIN
            Q
         END Q;
   END P;

END M.

There are three scopes in this module:

1. the global scope of M
2. the local scope of P
3. the local scope of Q.

P is declared in the global scope of M, Q is declared in the local scope
of P and nothing is declared in the local scope of Q. Without the sentence

"The use of the procedure identifier in a call within its declaration
implies recursive activation of the procedure."

in the Oberon-07 language report the module would not be valid since in
Oberon-07 we cannot access intermediate scopes; Q is called in the local
scope of Q (where nothing is defined) and the global scope has only P so
no Q in sight.

Now, the quoted sentence above can be read as

A) an exception to the usual scope rules (in which the module is valid) or

B) a rule which doesn't "violate" the scope rules (in which the module
is invalid) and which implies that only global procedures can call
themselves.

If I understand you correctly, Diego, you interpret it as A. The third
possibility is that I'm wrong about "each identifier exists in exactly
one scope"; can Q exist both in the local scope of P *and* in the local
scope of Q?

Please, tell me where I'm wrong in my reasoning.

> Did you try that in Project Oberon 2013?

Yes, the module is accepted by the Project Oberon compiler but on the
other hand this compiler accepts a few other things which is in conflict
with the language report such as for instance structural equivalence of
arrays.


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



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.inf.ethz.ch/pipermail/oberon/attachments/20231210/2e19ecf1/attachment.html>


More information about the Oberon mailing list