Newsgroups: | comp.compilers |
From: | chase@centerline.com (David Chase) |
Keywords: | C++, optimize |
Organization: | CenterLine Software |
References: | 95-07-068 95-07-141 |
Date: | Fri, 28 Jul 1995 18:14:30 GMT |
jhallen@world.std.com (Joseph H Allen) writes:
> One "good reason" is if/when named (as opposed to positional) parameters
> ever get added to C++ (I'm having to deal with this issue now with my
> language Ivy). For example:
> foo(`x=7,`y=8) and foo(`y=8,`x=7) are equivalent.
> So do you evaluate them in order of appearance or in the order they are
> pushed on the stack (which probably depends on how the function was
> defined)?
Obviously, you evaluate them in the order of appearance. That
will be most intuitive to the programmer, and should the programmer
actually need this level of control, they have it.
> But it may require the compiler to allocate stack for parameters before
> they are evaluated in the case where the language has named parameters.
But does this matter? In the grand scheme of things, how much performance
is won by doing this optimization (that nobody seems to do anyway)? Has
anyone measured it?
> More syntax could easily be added to
> force various orders of evluation:
> foo(parallel(x,y,leftright(z,q,parallel(a,b))))
Run away! Run away! Run away! Yuck, ugh, ick.
Besides which, if you're going to be this ugly, I think you should go
whole hog -- use the indentation level of parameters to specify the
evaluation order and possible parallelism. To make it clear that this
was intended, I'd introduce a slight frob on the normal parameter list
parentheses, since otherwise running indent might change the behavior of
your program (or the performance). I was thinking of something like this:
foo(-:
x,
y,
z,
q,
a,
b :-) ;
(Now, watch some crazy person take this seriously.)
speaking for myself,
David Chase
--
Return to the
comp.compilers page.
Search the
comp.compilers archives again.