Path: utzoo!mnetor!uunet!lll-winken!lll-lcc!lll-tis!ames!rutgers!mtune!whuts!homxb!ihnp4!alberta!teletron!andrew From: andrew@teletron.UUCP (Andrew Scott) Newsgroups: comp.lang.c Subject: Re: == vs = Message-ID: <211@teletron.UUCP> Date: 25 Jan 88 22:31:32 GMT References: <11216@brl-adm.ARPA> <2111@chinet.UUCP> <4403@garfield.UUCP> <3208@bunker.UUCP> Organization: TeleTronic Communications Ltd., Edmonton, Alta. Lines: 20 In article <3208@bunker.UUCP>, garys@bunker.UUCP (Gary M. Samuelson) writes: > When I see "if (x = fn())", I know what it means, but sometimes I > am not sure whether the author meant "if (x = fn())" or > "if (x == fn())". I spend a lot of time trying to figure out > what other programmers meant, even after I figure out what > they wrote. "if( (x = fn()) != 0 )" is longer, but it is > totally unambiguous to both the author and the (human) reader. Not only is the "if ((x = fn()) != 0)" form unambiguous to the human reader, it generates *identical* code as the "if (x = fn())" form does (at least on the compiler I use). It makes a lot sense to make your intentions as a programmer clear to other (future) programmers during the maintenance phase of the software's life cycle, as Gary mentioned in his posting. There is no point in using the shorthand form, unless laziness is a virtue. Andrew Scott -- $ make sense Make: Don't know how to make sense. Stop.