home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.modula2
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!rpi!ghost.dsi.unimi.it!univ-lyon1.fr!chx400!bernina!neptune!templ
- From: templ@inf.ethz.ch (Josef Templ)
- Subject: Re: Oberon vs Modula-2
- Message-ID: <1992Nov21.095307.19198@neptune.inf.ethz.ch>
- Sender: templ@inf.ethz.ch
- Nntp-Posting-Host: lillian-gw
- Organization: Dept. Informatik, Swiss Federal Institute of Technology (ETH), Zurich, CH
- Date: Sat, 21 Nov 1992 09:53:07 GMT
- Lines: 61
-
-
- A. Borchert writes:
- > Here an example, following program is perfectly legal Oberon text
- > but rejected by the Sparc Oberon System from ETH Zurich:
- >
- > (* CLASS=CONFORMANCE *)
- > MODULE t03;
- > TYPE c = RECORD a, b: INTEGER END;
- > PROCEDURE e;
- > TYPE b = POINTER TO c;
- > c = ARRAY 3 OF CHAR;
- > VAR p: b;
- > BEGIN (* e *)
- > p^[1] := "x";
- > END e;
- > END t03.
- > The compiler complains at the designator >>p^[1]<< that
- > "indexed variable is not an array".
-
- Section 4 (Declarations and Scope rules) of the Oberon-2 Report:
- The scope of an object x extends textually from the point of its declaration
- to the end of the block (module, procedure, or record) to which the
- declaration belongs and hence to which the object is local.
-
- and in the same section:
- A type T of the form POINTER TO T1 (see 6.4) can be declared before
- the scope of T1. In this case, the declaration of T1 must follow in
- the same block to which T is local;
-
- I think this is an ambiguity in the language definition.
- The forward declaration rule should be explicitely restricted to
- the cases where T1 is not visible at the point of the forward declaration.
- Anyway, the intention is that the above program is neither legal
- Oberon nor legal Oberon-2.
-
-
- > MODULE RecAssignment;
- > TYPE T0 = RECORD END;
- > T1 = RECORD (T0) END;
- > VAR t1a, t1b: T1;
- > PROCEDURE AssignIt(VAR ta, tb: T0);
- > BEGIN
- > ta := tb; (* statically the same type and ... *)
- > END AssignIt;
- > BEGIN
- > AssignIt(t1a, t1b); (* ... dynamically the same type *)
- > END RecAssignment;
- >
- > is perfectly legal in Oberon but not in Oberon-2. But, of course,
- > this feature was never implemented in ETH compilers (tell me if
- > I'm wrong here).
-
- Both Oberon and Oberon-2 compilers will compile the above module.
- The context condition "Te and Tv are record types and Te is an extension
- of Tv and the dynamic type of v is Tv" cannot be fully checked at compile time
- but compiles into a runtime check in both Oberon and Oberon-2.
- The original Oberon-Report does not mention implicit runtime
- checks (c.f. array indices, ...).
-
- - Josef Templ
- the usual disclaimer applies
-