Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!sharkey!bnlux0!drs From: drs@bnlux0.bnl.gov (David R. Stampf) Newsgroups: comp.lang.c Subject: Re: What I'd really like to see in an if-statement... Message-ID: <1395@bnlux0.bnl.gov> Date: 6 Aug 89 21:13:11 GMT References: <5024@alvin.mcnc.org> <1300@atanasoff.cs.iastate.edu> <456@helios.prosys.se> <14521@bfmny0.UUCP> Reply-To: drs@bnlux0.UUCP (David R. Stampf) Organization: Brookhaven National Lab., Upton, N.Y. Lines: 26 In article <14521@bfmny0.UUCP> tneff@bfmny0.UUCP (Tom Neff) writes: >The complex expression > > val1 < x < val2 > >(and by extension, the 24 other forms possible with <, <=, ==, >= and >) >really has nothing to do with the 'if' statement, so the subject name >of this thread is inaccurate. What's wished for is a triadic comparison >operator, ... >... >"We walked on the moon -- (( Tom Neff > you be polite" )) tneff@bfmny0.UU.NET How true. One of my *favorite* features of smallTalk is how one can compare a number (actually a magnitude) for inclusion in an interval, and how SmallTalk does C one better by making "if" an operator as well! For example, one can write: (x between: val1 and: val2) ifTrue: [ "do this block if true"] ifFalse: [ "do this block otherwise"]. Pretty neat stuff. I would imagine that C++ could handle such a construct. One of these days I'll have a C++ compiler to try it. < dave