home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / lang / modula2 / 1440 < prev    next >
Encoding:
Internet Message Format  |  1992-11-23  |  1.7 KB

  1. Path: sparky!uunet!zaphod.mps.ohio-state.edu!uwm.edu!biosci!agate!apple!mumbo.apple.com!gallant.apple.com!cheryl
  2. From: cheryl@gallant.apple.com (Cheryl Lins)
  3. Newsgroups: comp.lang.modula2
  4. Subject: Re: Oberon vs Modula-2
  5. Summary: Forward refs to base types
  6. Message-ID: <1992Nov23.174129.25457@gallant.apple.com>
  7. Date: 23 Nov 92 17:41:29 GMT
  8. References: <1992Nov21.095307.19198@neptune.inf.ethz.ch>
  9. Organization: Apple Computer Inc, Cupertino, CA
  10. Lines: 35
  11.  
  12. In article <1992Nov21.095307.19198@neptune.inf.ethz.ch> templ@inf.ethz.ch (Josef Templ) writes:
  13. >
  14. >A. Borchert writes:
  15. >> Here an example, following program is perfectly legal Oberon text
  16. >> but rejected by the Sparc Oberon System from ETH Zurich:
  17. >> 
  18. >> (* CLASS=CONFORMANCE *)
  19. >> MODULE t03;
  20. >>    TYPE c = RECORD a, b: INTEGER END;
  21. >>    PROCEDURE e;
  22. >>       TYPE b = POINTER TO c;
  23. >>          c = ARRAY 3 OF CHAR;
  24. >>       VAR p: b;
  25. >>    BEGIN (* e *)
  26. >>       p^[1] := "x";
  27. >>    END e;
  28. >> END t03.
  29. >> The compiler complains at the designator >>p^[1]<< that
  30. >> "indexed variable is not an array".
  31. >
  32. >I think this is an ambiguity in the language definition.
  33. >The forward declaration rule should be explicitely restricted to
  34. >the cases where T1 is not visible at the point of the forward declaration.
  35. >Anyway, the intention is that the above program is neither legal
  36. >Oberon nor legal Oberon-2.
  37. >
  38.  
  39. Of course, it's legal. It's just not what the programmer intended :-)
  40. The "c" referred to in "b = POINTER TO c" is the record structure declared in
  41. the outer scope. So obviously, using indexing on a record generates an error
  42. in >>p[1]<<. 
  43.  
  44. -- 
  45. Cheryl Lins  Oberon Paladin  lins@apple.com
  46. "Beware the following code - I've only proven it correct, not tested it" Knuth
  47.