Path: utzoo!mnetor!uunet!seismo!sundc!pitstop!sun!decwrl!labrea!aurora!ames!hao!noao!arizona!naucse!sbw From: sbw@naucse.UUCP (Steve Wampler) Newsgroups: comp.lang.c Subject: Re: The D Programming Language Message-ID: <580@naucse.UUCP> Date: 17 Feb 88 14:41:56 GMT References: <11702@brl-adm.ARPA> <558@naucse.UUCP> <2523@haddock.ISC.COM> <2595@haddock.ISC.COM> Organization: Northern Arizona University, Flagstaff, AZ Lines: 33 In article <2595@haddock.ISC.COM>, karl@haddock.ISC.COM (Karl Heuer) writes: > In article <563@naucse.UUCP> sbw@naucse.UUCP (Steve Wampler) writes: > >> > i(x1, x2, x3, ..., xn) > >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 > >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.) Actually, no. However, I wasn't thinking of this as an exact replacement for the ',,' operator, just as something that does equivalent work. You can evaluate all the operands and then fairly easily make an arbitrary one of them available. Think of 'i(x1, x2, x3,..., xn)' as being analogous to calling a function 'i' that returns its ith argument. Then think of ways to avoid implementing 'i' as a function. I suppose that compared to the ',,' operator, there is the overhead of verifying that 'i' evaluated to the proper range, but that is really a cost of the extra generality, and can be eliminated if 'i' is a constant. Of course, the evaluation order for ',,' is well defined, while the evaluation order (in 'C' at least) for 'i(...)' would match the evaluation order for function calls, which is much messier. (In 'D', however....). I think ',,' is an interesting operator, but I personnally prefer 'i(...)', having used it extensively in Icon - it seems 'more natural' to me. To each his own. -- Steve Wampler {....!arizona!naucse!sbw}