Path: utzoo!mnetor!uunet!husc6!cmcl2!nrl-cmf!ames!ucsd!sdcsvax!ucsdhub!hp-sdd!hplabs!hpda!hpcupt1!hpisod2!decot From: decot@hpisod2.HP.COM (Dave Decot) Newsgroups: comp.lang.c Subject: Re: The D Programming Language: values and voids (was: == vs =) Message-ID: <2550071@hpisod2.HP.COM> Date: 13 Apr 88 05:18:30 GMT References: <3290@haddock.ISC.COM> Organization: Hewlett Packard, Cupertino Lines: 32 > I think this is better written as "if ((status = *statreg))"; some > people even recommend "if ((status = *statreg), status)".% > > If you write the if as "if (a = b)", many readers of your code > (possibly including yourself) will first think "aha, this is a typo". > Many other readers will read it as "if (a == b)". It is therefore a > good idea to use a visually distinct form. The two forms I list above > both result from the idea that `=' should not be the top level operator > in a conditional expression. I agree with the reasoning, but I think an even clearer way of expressing what you really mean is this: if ((status = *statreg) != 0) ... Generally, I will only use an implied comparison to 0 in conditional contexts when the name of a "Boolean" variable or macro returning a purely "Boolean" result is the entirety of the condition. For instance, if (strcmp(x, y) != 0) ... but if (isprint(*p)) ... Dave Decot hpda!decot