Path: utzoo!attcan!uunet!zephyr.ens.tek.com!uw-beaver!mit-eddie!bloom-beacon!eru!luth!sunic!tut!funic!santra!cs.hut.fi!jem From: jem@cs.hut.fi (Johan Myreen) Newsgroups: comp.lang.modula2 Subject: Re: Why are the loops so awkward? Message-ID: Date: 19 Jun 90 21:38:47 GMT References: <5377.26731960@puddle.fidonet.org> <728.26767558@waikato.ac.nz> <22282@boulder.Colorado.EDU> <1990Jun18.180933.793@urz.unibas.ch> <22422@boulder.Colorado.EDU> Sender: news@santra.uucp (Cnews - USENET news system) Organization: Helsinki University of Technology, Finland Lines: 24 In-Reply-To: wolniewi@boulder.Colorado.EDU's message of 19 Jun 90 15:59:48 GMT In article <22422@boulder.Colorado.EDU> wolniewi@boulder.Colorado.EDU (Richard Wolniewicz) writes: >(not clearly stated in my last posting) is this; does the Modula 2 language >insure that a short circuit evaluation of an expression will evaluate the >different components in order of appearance in the code. For example, in the >code below, >IF A() OR B THEN ... >where A is a function call returning a BOOLEAN, and B is a BOOLEAN variable, >does Modula 2 insure that A will be called, or could the compiler optimize Yes. Also, if A() is TRUE, B will not be evaluated at all. The order is left to right, and as soon as the result is known evaluation stops. Someone said in an earlier message that this was not the case in some compilers, and that it is the implementer's choice whether the compiler supports this feature or not. This is not true. If a compiler doesn't implement short circuit evaluation, it isn't a Modula-2 compiler. -- Johan Myreen jem@cs.hut.fi