The D Programming Language

Karl Heuer karl at haddock.ISC.COM
Wed Feb 17 09:14:35 AEST 1988


In article <563 at naucse.UUCP> sbw at 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 at haddock.isc.com), The Walking Lint



More information about the Comp.lang.c mailing list