"arithmetic if":: Re: Feature for the next C version

Karl Heuer karl at haddock.ima.isc.com
Fri Aug 4 00:45:52 AEST 1989


In article <1429 at crdgw1.crd.ge.com> davidsen at crdos1 (bill davidsen) writes:
>...Again thanks for all the input, hopefully any new standard will come
>up with a reasonable way to write this, to (a) make it easy to read, (b)
>make it easy for compilers to generate good code (ie. recognize the
>special case).

I don't expect it'll ever make it into a C standard.  It's useful, but not
sufficiently useful to be worth the "feature pollution".

>Obviously no one wants to have labels, but perhaps something like:
>	n = (a-b $ -1 : 0 : 1);
>where there would be a "quadratic operator."

This brings up something I haven't seen mentioned here yet.  (a < b) is *not*
equivalent to (a-b < 0) if the latter expression might overflow.  (This was
also a major flaw in the original fortran concept.)  What you really want is a
pentadic operator:
	n = (a ?? b -> -1 , 0 , 1);
(Syntax flames to /dev/null; I'm not really proposing this.)

Karl W. Z. Heuer (ima!haddock!karl or karl at haddock.isc.com), The Walking Lint
(PS: I think the word for 4-adic is "tetradic" or "quadary", not "quadratic".)



More information about the Comp.lang.c mailing list