Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!rutgers!lll-lcc!seismo!mimsy!chris From: chris@mimsy.UUCP Newsgroups: comp.lang.c Subject: Re: short circuit evaluation Message-ID: <5200@mimsy.UUCP> Date: Sun, 25-Jan-87 21:24:19 EST Article-I.D.: mimsy.5200 Posted: Sun Jan 25 21:24:19 1987 Date-Received: Tue, 27-Jan-87 02:31:33 EST References: <425@bobkat.UUCP> <102600001@datacube> <34@umich.UUCP> <621@sdchema.sdchem.UUCP> Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 29 In article <621@sdchema.sdchem.UUCP> tps@sdchem.UUCP (Tom Stockfisch) writes: >"&" and "|" are like "+" and "-" in that you are not guaranteed that >the left side will be [fully] evaluated before the right [or vice versa]. >Read K&R sections 7.8-10, p. 190: > "The [&|^] operator is associative and expressions involving [&|^] > may be rearranged." This is a good point too. It gets worse all the time! :-) >I agree with you that the evaluation might be short circuited if the result >is already known. However, I don't think this is guaranteed, Of course not. Intuitive languages make few guarantees.... :-) >it might happen in the reverse order (right operand evaluated, >left operand skipped), That was one of the possibilities I enumerated. >and it is guaranteed not to happen if the to-be-skipped operand has a >side effect. Is it? (This is one reason optimising compilers are so difficult to write: No one is sure just how much they are allowed to do....) -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7690) UUCP: seismo!mimsy!chris ARPA/CSNet: chris@mimsy.umd.edu