What I'd really like to see in an if-statement...

David R. Stampf drs at bnlux0.bnl.gov
Mon Aug 7 07:13:11 AEST 1989


In article <14521 at bfmny0.UUCP> tneff at 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 at 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



More information about the Comp.lang.c mailing list