home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / lang / modula2 / 1426 < prev    next >
Encoding:
Text File  |  1992-11-21  |  2.6 KB  |  73 lines

  1. Newsgroups: comp.lang.modula2
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!rpi!ghost.dsi.unimi.it!univ-lyon1.fr!chx400!bernina!neptune!templ
  3. From: templ@inf.ethz.ch (Josef Templ)
  4. Subject: Re: Oberon vs Modula-2
  5. Message-ID: <1992Nov21.095307.19198@neptune.inf.ethz.ch>
  6. Sender: templ@inf.ethz.ch
  7. Nntp-Posting-Host: lillian-gw
  8. Organization: Dept. Informatik, Swiss Federal Institute of Technology (ETH), Zurich, CH
  9. Date: Sat, 21 Nov 1992 09:53:07 GMT
  10. Lines: 61
  11.  
  12.  
  13. A. Borchert writes:
  14. > Here an example, following program is perfectly legal Oberon text
  15. > but rejected by the Sparc Oberon System from ETH Zurich:
  16. > (* CLASS=CONFORMANCE *)
  17. > MODULE t03;
  18. >    TYPE c = RECORD a, b: INTEGER END;
  19. >    PROCEDURE e;
  20. >       TYPE b = POINTER TO c;
  21. >          c = ARRAY 3 OF CHAR;
  22. >       VAR p: b;
  23. >    BEGIN (* e *)
  24. >       p^[1] := "x";
  25. >    END e;
  26. > END t03.
  27. > The compiler complains at the designator >>p^[1]<< that
  28. > "indexed variable is not an array".
  29.  
  30. Section 4 (Declarations and Scope rules) of the Oberon-2 Report:
  31.   The scope of an object x extends textually from the point of its declaration 
  32.   to the end of the block (module, procedure, or record) to which the 
  33.   declaration belongs and hence to which the object is local.
  34.  
  35. and in the same section:
  36.   A type T of the form POINTER TO T1 (see 6.4) can be declared before
  37.   the scope of T1. In this case, the declaration of T1 must follow in
  38.   the same block to which T is local;
  39.  
  40. I think this is an ambiguity in the language definition.
  41. The forward declaration rule should be explicitely restricted to
  42. the cases where T1 is not visible at the point of the forward declaration.
  43. Anyway, the intention is that the above program is neither legal
  44. Oberon nor legal Oberon-2.
  45.  
  46.  
  47. > MODULE RecAssignment;
  48. >    TYPE T0 = RECORD END;
  49. >         T1 = RECORD (T0) END;
  50. >    VAR t1a, t1b: T1;
  51. >    PROCEDURE AssignIt(VAR ta, tb: T0);
  52. >    BEGIN
  53. >       ta := tb; (* statically the same type and ... *)
  54. >    END AssignIt;
  55. > BEGIN
  56. >    AssignIt(t1a, t1b); (* ... dynamically the same type *)
  57. > END RecAssignment;
  58. > is perfectly legal in Oberon but not in Oberon-2. But, of course,
  59. > this feature was never implemented in ETH compilers (tell me if
  60. > I'm wrong here).
  61.  
  62. Both Oberon and Oberon-2 compilers will compile the above module.
  63. The context condition "Te and Tv are record types and Te is an extension
  64. of Tv and the dynamic type of v is Tv" cannot be fully checked at compile time
  65. but compiles into a runtime check in both Oberon and Oberon-2.
  66. The original Oberon-Report does not mention implicit runtime
  67. checks (c.f. array indices, ...).
  68.  
  69. - Josef Templ
  70. the usual disclaimer applies
  71.