home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / lang / scheme / 2878 < prev    next >
Encoding:
Text File  |  1993-01-06  |  2.7 KB  |  56 lines

  1. Newsgroups: comp.lang.scheme
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!rpi!ghost.dsi.unimi.it!univ-lyon1.fr!chx400!bernina!neptune!nugget.inf.ethz.ch!marti
  3. From: marti@nugget.inf.ethz.ch (Robert Marti)
  4. Subject: Re: applying or
  5. Message-ID: <1993Jan6.215411.28927@neptune.inf.ethz.ch>
  6. Sender: news@neptune.inf.ethz.ch (Mr News)
  7. Nntp-Posting-Host: nugget.inf.ethz.ch
  8. Organization: Dept. Informatik, Swiss Federal Institute of Technology (ETH), Zurich, CH
  9. References: <1hsiocINN2v6@columbia.cs.ubc.ca> <1992Dec31.181545.19917@sharebase.com> <1993Jan5.165545.11990@neptune.inf.ethz.ch> <1993Jan6.164736.10682@daffy.cs.wisc.edu>
  10. Date: Wed, 6 Jan 1993 21:54:11 GMT
  11. Lines: 43
  12.  
  13. In article <1993Jan6.164736.10682@daffy.cs.wisc.edu>,
  14. quale@spock.cs.wisc.edu (Doug Quale) writes in response
  15. to an earlier article by me:
  16. |> >Pascal as described in the 1st ed. of Jensen & Wirth did indeed specify
  17. |> >that both the left _and_ right Boolean sub-expression of AND and OR must
  18. |> >_always_ be evaluated.
  19. |> 
  20. |> Could you provide the page number that says this?  This directly conflicts
  21. |> with my recollection that the User Manual and Report is completely silent
  22. |> on this issue.  This is one of the Report's several bugs, but it was
  23. |> pretty good for its time.
  24. |> 
  25. |> In a quick scan of the second edition (the one I had handy, but I can
  26. |> get the first edition from the library) I couldn't find anything.  My
  27. |> understanding is that short-circuit evaluation is compatible with the
  28. |> requirements of the User Manual and Report, but is not required.  Many
  29. |> early Pascal compilers didn't do short-circuit evaluation, and ultimately
  30. |> many used the CDC implementation from ETH as the final arbiter on the
  31. |> ambiguities in the definition.  (This was clearly less than ideal.)
  32.  
  33. Ahem.  I think you're pretty much correct here.  I couldn't find anything
  34. in the 2nd Edition of J&W either, although I didn't search extensively.
  35. (Interestingly enough, I had absolutely no problem to find the relevant
  36. stuff in the "Report on the Programming Language Modula-2" contained in
  37. N. Wirth, "Programming in Modula-2", 3rd, Corrected Ed., Springer, 1985,
  38. where it says on p. 153:  "p OR q means 'if p then TRUE otherwise q' and
  39. p AND q means 'if p then q otherwise FALSE'".)
  40.  
  41. However, Wirth himself assumed that Pascal implementations would always
  42. evaluate both Boolean sub-expressons as can be seen e.g. in his Pascal
  43. code in the 1st edition of "Algorithms and Data Structures".
  44. Example:
  45.   if p <> nil then
  46.     if p^.key = x then
  47.       begin
  48.         (* do something here *)
  49.       end
  50.  
  51. -- 
  52. Robert Marti                    |  Phone:    +41 1 254 72 60
  53. Informationssysteme             |  FAX:      +41 1 262 39 73
  54. ETH-Zentrum                     |  E-Mail:   marti@inf.ethz.ch
  55. CH-8092 Zurich, Switzerland     |
  56.