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

Karl Heuer karl at haddock.ima.isc.com
Tue Aug 8 11:47:19 AEST 1989


Btw, one of my own pet ideas for "D" is the same notation in a loop construct:
	for (lo <= var < hi) ...
which would mean the same thing as C's
	for (var = lo; var < hi; ++var) ...
except that hi would be evaluated only once, and it would be illegal to change
the value of var within the loop.  (I.e., it would be your standard for-loop
as in BASIC/FORTRAN/PASCAL.)  All eight sensible combinations of relational
operators would be allowed.  (The construct
	for (hi > var >= lo) ...
would step through the same values via a decrementing loop.)

The only other proposal I've seen for such a feature uses notation like
	for (var in [lo, hi)) ...
but the syntax for the half-open interval is ugly.  (And "[lo, hi[" is worse.)

Karl W. Z. Heuer (ima!haddock!karl or karl at haddock.isc.com), The Walking Lint



More information about the Comp.lang.c mailing list