Path: utzoo!utgpu!water!watmath!clyde!ima!haddock!karl From: karl@haddock.ISC.COM (Karl Heuer) Newsgroups: comp.lang.c Subject: Re: The D Programming Language Summary: general pick-one operator Message-ID: <2595@haddock.ISC.COM> Date: 16 Feb 88 23:14:35 GMT References: <11702@brl-adm.ARPA> <558@naucse.UUCP> <2523@haddock.ISC.COM> <563@naucse.UUCP> Reply-To: karl@haddock.ima.isc.com (Karl Heuer) Organization: Interactive Systems, Boston Lines: 17 In article <563@naucse.UUCP> sbw@naucse.UUCP (Steve Wampler) writes: >> > i(x1, x2, x3, ..., xn) >> >[where 1 <= i <= n; the result is xi] >[Karl Heuer states that the generalization to nonconstant `i' is expensive] >Actually, if 'i' is an arbitrary integral expression, it isn't that much more >expensive to implement than if it's a constant - most of the evaluation >mechanism is already in place in C (excuse me, 'D'). The only extra expense >over computing the value if 'i' is a constant is the cost of evaluating the >expression for 'i' and a simple transfer. Sorry, I stand by my statement. If this `pick' operator is supposed to be a generalization of my proposed `,,' operator, it must preserve the guarantee of evaluating all of the `x?' operands, in left-to-right order. It sounds like you're thinking of the expression equivalent of `switch', which would evaluate exactly one of them. (Which may also be useful, but that's a separate topic.) Karl W. Z. Heuer (ima!haddock!karl or karl@haddock.isc.com), The Walking Lint