Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ames!ncar!ico!ism780c!haddock!karl From: karl@haddock.ima.isc.com (Karl Heuer) Newsgroups: comp.lang.c Subject: Re: "arithmetic if":: Re: Feature for the next C version Message-ID: <14181@haddock.ima.isc.com> Date: 3 Aug 89 14:45:52 GMT References: <55480@tut.cis.ohio-state.edu> <1989Jul20.152935.14872@utzoo.uucp> <67@motto.UUCP> <18764@mimsy.UUCP> <1389@crdgw1.crd.ge.com> <8515@batcomputer.tn.cornell.edu> <1429@crdgw1.crd.ge.com> Reply-To: karl@haddock.ima.isc.com (Karl Heuer) Organization: Interactive Systems, Boston Lines: 22 In article <1429@crdgw1.crd.ge.com> davidsen@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@haddock.isc.com), The Walking Lint (PS: I think the word for 4-adic is "tetradic" or "quadary", not "quadratic".)