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