Feature for the next C version

Ray Spalding cc100aa at prism.gatech.EDU
Sun Jul 30 11:00:35 AEST 1989


In article <1913 at prune.bbn.com> rsalz at bbn.com (Rich Salz) writes:
>...
>Easy enough.  First, create a helper function:
>    int
>    sgn(x)
>	int x;
>    {
>	return x ? (x < 0 : -1 : 1) : 0;
	                  ^
>    }
>...

That colon should be a question mark, I believe.

My understanding of the arithmetic (3-way branch) IF in Fortran is
that in ancient (pre '66) compilers it was often the ONLY type of
conditional branch implemented.  In an attempt to be "portable",
many programmers used this type of IF exclusively.

IMHO, arithmetic IFs make programs needlessly difficult to understand.
This is due to the expression having to work out relative to zero, and
(as was pointed out before) the number of statement labels and goto's
required.  I hope I never see another one.  And, I certainly hope no
such anachronism is ever adopted in C.
-- 
Ray Spalding
Georgia Institute of Technology, Atlanta Georgia, 30332
uucp:     ...!{allegra,amd,hplabs,ut-ngp}!gatech!prism!cc100aa
Internet: cc100aa at prism.gatech.edu



More information about the Comp.lang.c mailing list