Mathematical expression syntax (was: C vs. Fortran)

David Goodenough dg at lakart.UUCP
Tue Jul 5 07:39:04 AEST 1988


In article <20509 at beta.lanl.gov> jlg at beta.lanl.gov (Jim Giles) writes:
>The converse is also true.  Anyone who can defend x+=(p=foo(b)?++i:i--)
>should have no trouble with the arithmetic IF.  The arithmetic IF is
>obsolete and is only maintained for backwards compatibility.  I don't
>know anyone who uses it for new code.  The above C code is still
>considered _good_ code?

I would not defend the above. I would rewrite it:

	if (foo(b))
	  p = ++i;
	else
	  p = i--;
	x += p;

Which achieves the same end. With modern optimizing compilers the difference
between these two is none (I just compiled both with Greenhills CC and the
assembler code for the above two code sections is IDENTICAL).
-- 
	dg at lakart.UUCP - David Goodenough		+---+
							| +-+-+
	....... !harvard!cca!lakart!dg			+-+-+ |
						  	  +---+



More information about the Comp.lang.c mailing list