home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!cis.ohio-state.edu!zaphod.mps.ohio-state.edu!sol.ctr.columbia.edu!ira.uka.de!math.fu-berlin.de!news.netmbx.de!Germany.EU.net!nixpbe!uranium!uranium!not-for-mail
- From: Josef Moellers <mollers.pad@sni.de>
- Newsgroups: comp.lang.c
- Subject: Re: Order of evaluation?
- Date: 5 Nov 1992 11:49:59 +0100
- Organization: Siemens Nixdorf Informationssysteme AG, Paderborn, Germany
- Lines: 33
- Sender: josef@uranium.sto.pdb.sni.de
- Message-ID: <1dau8nINNk59@uranium.sto.pdb.sni.de>
- References: <3736@dozo.and.nl> <1992Oct27.002204.11825@den.mmc.com> <josef.720691377@uranium> <1992Nov2.192805.17329@CSD-NewsHost.Stanford.EDU>
-
- In <1992Nov2.192805.17329@CSD-NewsHost.Stanford.EDU> amorgan@Xenon.Stanford.EDU (Crunchy Frog) writes:
-
- >In article <josef.720691377@uranium> Josef Moellers <mollers.pad@sni.de> writes:
- >>
- >>Furthermore, as "boolean" operations are nothing special in C, I wonder
- >>whether in
- >> a() || b()
- >>b _should_ be called if a() returns TRUE.
-
- >It shouldn't be. C has short circuit evaluation for && and ||.
-
- I'd like to clarify a mis-understanding.
- I _do_ know, how || and && work under C.
-
- The original thread was about whether a C-Compiler must arrange for
- first calling all functions and then evaluating the expressions.
-
- In my example, the original claim would mean that a() _and_ b() are
- called first, then the left side was (trivially) evaluated using the
- results of the call to a(), and if it was found to be TRUE, the result
- of the call to b() was dropped.
-
- My understanding was (and still is), that functions need only be called
- as far as necessary.
- E.g. in an expression like
- a() * b() * c() * e() * f() * g()
- the compiler might decide to generate code to test the intermediate
- result to be 0, in which case the rest of the expression might be
- dropped.
- --
- | Josef Moellers | c/o Siemens Nixdorf Informationssysteme AG |
- | USA: mollers.pad@sni-usa.com | Abt. STO-XS 113 | Riemekestrasse |
- | !USA: mollers.pad@sni.de | Phone: (+49) 5251 835124 | D-4790 Paderborn |
-