Path: utzoo!mnetor!uunet!husc6!necntc!ima!haddock!karl From: karl@haddock.ISC.COM (Karl Heuer) Newsgroups: comp.lang.c Subject: Re: The D Programming Language (was: Still more new operators) Message-ID: <2523@haddock.ISC.COM> Date: 9 Feb 88 17:37:56 GMT References: <11702@brl-adm.ARPA> <558@naucse.UUCP> Reply-To: karl@haddock.ima.isc.com (Karl Heuer) Organization: Interactive Systems, Boston Lines: 33 In article <558@naucse.UUCP> rrr@naucse.UUCP (Bob Rose ) writes: >But wait, we can do better [than the proposed ",,"]. Why limit yourself to >two operands? > i(x1, x2, x3, ..., xn) >[where 1 <= i <= n; the result is xi] If `i' is constant, this is no more powerful than `(x1, ..., xi,, ...,, xn)' which produces the same result. If `i' is allowed to be an arbitrary integral expression (which I presume is the case in interpretive Icon), then it is indeed more powerful but also more expensive to compute. Part of the beauty of `,,' is that it has a cost comparable to `,'. >[How about an operator] that produces it first operand if it is not zero else >it produces it second I considered proposing that the `||' operator be so extended (yes, this could break existing code, but only if the operands are nonboolean AND the result is being used in a nonboolean context). After thinking about it, though, I decided that this is a step backwards. In programs that properly distinguish between booleans and integers, there's nothing particularly magic about `compare against zero'. Why should there be a special-purpose notation for `e1 != 0 ? e1 : e2' but not for `e1 != -1 ? e1 : e2', say? What you really want is the `it' pronoun, often used in PDL. IF long-hairy-expression != 0 RETURN it ELSE RETURN other-expression ENDIF Karl W. Z. Heuer (ima!haddock!karl or karl@haddock.isc.com), The Walking Lint KWZH: We need a construct like `e1 UNLESS IT==0 INWHICHCASE e2'. GCJ: Yes, and also `IFONTHEOTHERHAND ... WEMAYSAFELYASSUME'.