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

  1. Newsgroups: comp.lang.modula2
  2. Path: sparky!uunet!mcsun!news.funet.fi!network.jyu.fi!sakkinen
  3. From: sakkinen@jyu.fi (Markku Sakkinen)
  4. Subject: Re: Oberon vs Modula-2 (Re: mail delivery error)
  5. Message-ID: <1992Nov19.104407.338@jyu.fi>
  6. Organization: University of Jyvaskyla, Finland
  7. References: <1992Nov13.130852.22775@jyu.fi> <1992Nov16.080647.26783@informatik.uni-ulm.de> <1992Nov17.155855.4413@let.rug.nl>
  8. Date: Thu, 19 Nov 1992 10:44:07 GMT
  9. Lines: 34
  10.  
  11. In article <1992Nov17.155855.4413@let.rug.nl> bert@let.rug.nl (Bert Bos) writes:
  12. >In article <1992Nov16.080647.26783@informatik.uni-ulm.de>, borchert@titania.mathematik.uni-ulm.de (Andreas Borchert) writes:
  13. >> Agreed, programmers shouldn't be enforced to use VAR-parameters
  14. >> for reasons of efficiency only. But, even with the semantics of
  15. >> Oberon or Modula-2, it's not to difficult for the compiler to
  16. >> detect that your 1000 x 1000 array isn't modified and, thus,
  17. >> doesn't need to be copied.
  18. >> ...
  19. >But what about a PROCEDURE p(a: Type; VAR b: Type) that is called as p(x, x). Both parameters will refer to x, but if b is modified, a should remain unchanged.
  20.  
  21. A good point, showing that my suggestion of constant vs. variable
  22. is worse that value vs. variable as far as regards aliassing problems.
  23. Thus, there would indeed be some merit in having three parameter modes
  24. (as somebody suggested in this thread):
  25. value, constant, and variable (and possibly yet something like 'out'
  26. in Ada, i.e. a result parameter).
  27.  
  28. Fortran, I think, has a rule stating that if a formal parameter is
  29. modified within a subprogram, the corresponding actual parameter must
  30. not be the same as any other actual parameter in the call.
  31. Does Modula-2 or Oberon have a similar rule?  (Value parameters need
  32. not be considered, but constant parameters would if passed by reference.)
  33. Of course, those breaches of the rule that cannot be detected at compile
  34. time could be too expensive to catch at run time.
  35.  
  36. ----------------------------------------------------------------------
  37. Markku Sakkinen (sakkinen@jytko.jyu.fi)
  38.        SAKKINEN@FINJYU.bitnet (alternative network address)
  39. Department of Computer Science and Information Systems
  40. University of Jyvaskyla (a's with umlauts)
  41. PL 35
  42. SF-40351 Jyvaskyla (umlauts again)
  43. Finland
  44. ----------------------------------------------------------------------
  45.