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

  1. Newsgroups: comp.lang.modula2
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!sol.ctr.columbia.edu!ira.uka.de!ira.uka.de!math.fu-berlin.de!news.belwue.de!theorie!titania.mathematik.uni-ulm.de!borchert
  3. From: borchert@titania.mathematik.uni-ulm.de (Andreas Borchert)
  4. Subject: Re: Oberon vs Modula-2
  5. Message-ID: <1992Nov20.125458.25797@informatik.uni-ulm.de>
  6. Sender: usenet@informatik.uni-ulm.de (Name for nntp-posting)
  7. Nntp-Posting-Host: titania.mathematik.uni-ulm.de
  8. Organization: University of Ulm, SAI
  9. References: <9211091022.A01745@MAIL.CASI.NASA.GOV> <5897@balrog.ctron.com> <BEVAN.92Nov18195812@tiger.cs.man.ac.uk>
  10. Date: Fri, 20 Nov 92 12:54:58 GMT
  11. Lines: 110
  12.  
  13. In article <BEVAN.92Nov18195812@tiger.cs.man.ac.uk>, bevan@cs.man.ac.uk (Stephen J Bevan) writes:
  14. > In article <1992Nov13.100154.6167@informatik.uni-ulm.de> borchert@titania.mathematik.uni-ulm.de (Andreas Borchert) writes:
  15. >    Don't forget that Oberon still needs less than 20 pages of language
  16. >    description.
  17. > Maybe be so, but it doesn't include a formal definition of the context
  18. > constraints (static semantics if you will) nor the dynamic semantics.
  19. > You may think it doesn't require either, however I've personally
  20. > struggled to make sense of the typing rules in the appendix (some of
  21. > which IMHO are redundant!) in an implementaion of a Oberon-2 front
  22. > end.  I found myself having to write bits of code and try them out
  23. > using the ETH compiler to see what (if any) errors it produced.
  24.  
  25. The typing rules in the appendix are in some cases redundant -- that's
  26. probably the reason why they have been put into an appendix.
  27.  
  28. It's always dangerous to follow foreign compilers (even those from ETH)
  29. because they probably never match the Oberon report exactly.
  30.  
  31. Here an example, following program is perfectly legal Oberon text
  32. but rejected by the Sparc Oberon System from ETH Zurich:
  33.  
  34. (* CLASS=CONFORMANCE *)
  35. MODULE t03;
  36.  
  37.    TYPE
  38.       c = RECORD a, b: INTEGER END;
  39.  
  40.    PROCEDURE e;
  41.       TYPE
  42.          b = POINTER TO c;
  43.          c = ARRAY 3 OF CHAR;
  44.       VAR
  45.          p: b;
  46.  
  47.    BEGIN (* e *)
  48.       p^[1] := "x";
  49.    END e;
  50.  
  51. END t03.
  52.  
  53. The compiler complains at the designator >>p^[1]<< that
  54. "indexed variable is not an array".
  55.  
  56. On the other hand, checking the ETH compiler may be a good idea,
  57. especially in those cases where the reports will be later adapted to
  58. their implementations. Examples:
  59.  
  60. (1)    The Oberon report published in Software Practice & Experience
  61.     contains two features which has been dropped in later versions:
  62.     (a) You may pass an extended pointer to a VAR-parameter, e.g.
  63.  
  64.         TYPE T0 = RECORD END; P0 = POINTER TO T0;
  65.          T1 = RECORD (T0) END; P1 = POINTER TO P1;
  66.         VAR p1: P1;
  67.  
  68.         PROCEDURE p(VAR p: P0); BEGIN ... END p;
  69.  
  70.         (* ... *)
  71.         p(p1);
  72.  
  73.     (b) ARRAY OF BYTE may be a call-by-value parameter
  74.     I doubt that they have ever implemented these features.
  75.  
  76. (2)    The Oberon report (ETH report 111, not Oberon-2!) declares in
  77.     9.1 that "The type of the expression must be included by the
  78.     type of the variable, or it must extend the type of the
  79.     variable."
  80.     This has been "clarified" in ETH report 160 (Oberon-2) in
  81.     the above mentioned appendix A: "An expression e of type Te
  82.     is assignment compatible with a variable v of type Tv if
  83.     one of the following conditions hold: ... 3. Te and Tv
  84.     are record types and Te is an extension of Tv and the
  85.     dynamic type of v is Tv.
  86.  
  87. (2) means that
  88.  
  89. MODULE RecAssignment;
  90.  
  91.    TYPE T0 = RECORD END;
  92.         T1 = RECORD (T0) END;
  93.    VAR
  94.       t1a, t1b: T1;
  95.  
  96.    PROCEDURE AssignIt(VAR ta, tb: T0);
  97.    BEGIN
  98.       ta := tb; (* statically the same type and ... *)
  99.    END AssignIt;
  100.  
  101. BEGIN
  102.    AssignIt(t1a, t1b); (* ... dynamically the same type *)
  103. END RecAssignment;
  104.  
  105. is perfectly legal in Oberon but not in Oberon-2. But, of course,
  106. this feature was never implemented in ETH compilers (tell me if
  107. I'm wrong here).
  108.  
  109. In summary, Oberon and Oberon-2 are (at least for ETH) research
  110. projects and, thus, subject to changes and development. So, you've to
  111. decide whether you want to be ETH-compatible or close to one of the
  112. reports. Nevertheless, there are still less questions open in
  113. these 18 pages (Oberon) or 26 pages (Oberon-2) than in any
  114. alternative 600-pages document (at least for me).
  115.  
  116. --
  117. _______________________________________________________________________________
  118.  
  119. Andreas Borchert, University of Ulm, SAI, D-W-7900 Ulm, Germany
  120. Internet: borchert@mathematik.uni-ulm.de
  121.