Path: utzoo!utgpu!watmath!att!ucbvax!tut.cis.ohio-state.edu!uc!uf!fin From: fin@uf.msc.umn.edu (Craig Finseth) Newsgroups: comp.lang.c Subject: Re: N-ary < operator (was What I'd really like to see in an if-statement...) Message-ID: <277@uc.msc.umn.edu> Date: 7 Aug 89 14:51:25 GMT References: <5024@alvin.mcnc.org> <1300@atanasoff.cs.iastate.edu> <456@helios.prosys.se> <14521@bfmny0.UUCP> <1864@salgado.Solbourne.COM> <8646@saturn.ucsc.edu> Sender: news@uc.msc.umn.edu Reply-To: fin@uf.UUCP (Craig Finseth) Organization: Minnesota Supercomputer Center, Minneapolis, MN Lines: 29 As previous posters have mentioned, the C language already accepts the syntax: a < b < c as valid, with (possibly) surprizing semantics. It is diffcult to imagine (i.e., I cannot) an upwardly-compatible extension to C that "corrects" the semantics. However, do not despair. You can achieve a similar goal merely be writing a function such as: int between(const int a, const int b, const int c) { return((a < b) && (b < c)); } which returns 1 if b is between a and c. While not as elegant as a built-in solution, it has the advantages of working on just about all C compilers (you can write it with the old-style parameter declarations) and use it now. (For the record, I added "between" (a < b < c), "outside" (c > b > a), and "within" (a <= b <= c) operators to a little-used data collection language that I developed.) Craig A. Finseth fin@msc.umn.edu [CAF13] Minnesota Supercomputer Center, Inc. (612) 624-3375