condition convention 'if (10 == j)...'

oacb2 oacb2 at ut-ngp.UUCP
Tue Apr 30 02:18:11 AEST 1985


> Just that instead of writing, in the traditional manner,
>	if(pc=malloc(nbytes)==NULL)...
> you have to insert extra parens if you use the other form:
>	if(NULL==(pc=malloc(nbytes)))..

Huh???  The first sets pc to 0 or 1 depending on whether the result of
malloc is or is not NULL.  The second sets pc to the result of malloc.

This seems to be another argument in favor of (CONSTANT == expression).
The first is probably incorrect, but legal C.

I think the (CONSTANT == expression) form is ugly.  That may just be that
it's not very familiar (guess it's been too many years since I used APL).
It does seem to have some merit though.
-- 

	Mike Rubenstein, OACB, UT Medical Branch, Galveston TX 77550



More information about the Comp.lang.c mailing list