Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!genrad!panda!husc6!harvard!topaz!bentley!kwh From: kwh@bentley.UUCP (KW Heuer) Newsgroups: net.lang.c Subject: Re: Boolean Operators Slighted in C Message-ID: <795@bentley.UUCP> Date: Tue, 6-May-86 09:44:24 EDT Article-I.D.: bentley.795 Posted: Tue May 6 09:44:24 1986 Date-Received: Wed, 7-May-86 06:10:35 EDT References: <12329@ucla-cs.ARPA> Organization: AT&T Bell Laboratories, Liberty Corner Lines: 39 In article <12329@ucla-cs.ARPA> jimc@ucla-cs.ARPA (Jim Carter) writes: >In article <778@bentley.UUCP> kwh@bentley.UUCP (KW Heuer) writes: >>Btw, you can't have *all* operators extended with "=". How would you write >>"v = v < e;"? (Not that it's useful.) > >I think it's useful! As written, of course, it's semantically invalid, Whoa! The operator I was referring to was "v = v < e", which is the clear generalization of "op=" on operator "<". This is meaningful in C, because the boolean result of "<" will be interpreted as an integer. But it is not generally useful, because one does not normally use a boolean argument to a comparison operator like "<". >but what you really mean is "v <= e" (sic) or, to demonstrate where it's >really useful, > array[horrendous] [subscript] [list] <= bigexpr; > rather than > if (array[h][s][l] < bigexpr) array[h][s][l] = bigexpr; Now we're discussing "if (v < e) v = e;" which means "v = max(v,e);". This is indeed a useful operation, but the operator is now "max" rather than "<". >Now "<=" already means something else so this syntax is not acceptable. >How about "v < = e" with a mandatory blank? This is atrocious human >engineering but at least is parseable. Anybody have any better ideas? Yes. I already mentioned this in the discussion about builtins, but I think it bears repeating. Introduce a new operator "<>" for max (and "><" for min). Add the corresponding assignment operator "<>=" (and "><=") with the above meaning. The symbol "<>" is currently meaningless in C, though basic and pascal users would have a fit. "|>" and "<|" may be better choices. "\/" and "/\" would mimic the mathematical notation, but there may be reasons to avoid the use of backslash in program source. Karl W. Z. Heuer (ihnp4!bentley!kwh), The Walking Lint