Re: Order of argument evaluation in C++, etc.

chase@centerline.com (David Chase)
Fri, 28 Jul 1995 18:14:30 GMT

          From comp.compilers

Related articles
[4 earlier articles]
Re: Order of argument evaluation in C++, etc. stefan.monnier@epfl.ch (Stefan Monnier) (1995-07-20)
Re: Order of argument evaluation in C++, etc. dmk@dmk.com (1995-07-21)
Re: Order of argument evaluation in C++, etc. jhallen@world.std.com (1995-07-21)
Re: Order of argument evaluation in C++, etc. hbaker@netcom.com (1995-07-26)
Re: Order of argument evaluation in C++, etc. karlcz@moraine.hip.berkeley.edu (1995-07-26)
Re: Order of argument evaluation in C++, etc. Steve_Kilbane@cegelecproj.co.uk (1995-07-26)
Re: Order of argument evaluation in C++, etc. chase@centerline.com (1995-07-28)
Re: Order of argument evaluation in C++, etc. davids@ICSI.Berkeley.EDU (1995-07-30)
Re: Order of argument evaluation in C++, etc. dave@occl-cam.demon.co.uk (Dave Lloyd) (1995-07-31)
Re: Order of argument evaluation in C++, etc. jthill@netcom.com (1995-08-03)
Re: Order of argument evaluation in C++, etc. chase@centerline.com (1995-08-07)
Re: Order of argument evaluation in C++, etc. hbaker@netcom.com (1995-08-08)
Re: Order of argument evaluation in C++, etc. graham.matthews@pell.anu.edu.au (1995-08-08)
[32 later articles]
| List of all articles for this month |
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
--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.