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

Thomas Way <way@cis.udel.edu>
Wed, 23 Aug 1995 17:38:22 GMT

          From comp.compilers

Related articles
[34 earlier articles]
Re: Order of argument evaluation in C++, etc. bobduff@world.std.com (1995-08-21)
Re: Order of argument evaluation in C++, etc. jan@neuroinformatik.ruhr-uni-bochum.de (1995-08-21)
Re: Order of argument evaluation in C++, etc. bill@amber.ssd.hcsc.com (1995-08-21)
Re: Order of argument evaluation in C++, etc. burley@gnu.ai.mit.edu (1995-08-23)
Re: Order of argument evaluation in C++, etc. jthill@netcom.com (1995-08-24)
Re: Order of argument evaluation in C++, etc. hbaker@netcom.com (1995-08-23)
Re: Order of argument evaluation in C++, etc. way@cis.udel.edu (Thomas Way) (1995-08-23)
Re: Order of argument evaluation in C++, etc. jmccarty@spdmail.spd.dsccc.com (1995-08-24)
Re: Order of argument evaluation in C++, etc. daniels@cse.ogi.edu (1995-08-24)
Re: Order of argument evaluation in C++, etc. pardo@cs.washington.edu (1995-08-25)
Re: Order of argument evaluation in C++, etc. hbaker@netcom.com (1995-08-25)
Re: Order of argument evaluation in C++, etc. jan@neuroinformatik.ruhr-uni-bochum.de (1995-08-25)
Re: Order of argument evaluation in C++, etc. stefan.monnier@epfl.ch (Stefan Monnier) (1995-08-28)
[2 later articles]
| List of all articles for this month |
Newsgroups: comp.compilers
From: Thomas Way <way@cis.udel.edu>
Keywords: optimize, C
Organization: University of Delaware, Newark
References: 95-08-067 95-08-146
Date: Wed, 23 Aug 1995 17:38:22 GMT

At the risk of sounding a bit naive in this whole debate
over order of evaluation, I have two points:


1) Perhaps if the order of evaluation of expressions whose
        results are passed as arguments is so important, these
        expressions should be evaluated prior to the actual
        fuction call. The itsy-bitsy teenie-tiny additional
        move or store/load operation is surely trivial. You are
        not talking orders of magnitude here, merely a slightly
        larger O(n) in additional overhead. Surely that is worth
        eliminating the needless fretting and worrying over`
        whether or not things are being evaluated in the order
        you hope they are.


2) In my opinion, it makes code difficult to read and support
        when function calls contain all sorts of expressions that
        are evaluated. Single statements tend to span lines more
        than necessary, and this alone slows down the task of
        digging through a year or two later to improve or otherwise
        rework pre-existing code... Particularly if it is not your
        own handiwork.


Hope this adds something to the debate.


-Tom Way
way@asel.udel.edu


[... some remnants ... heavily snipped ...]
In article 95-08-146,
David Chase <chase@centerline.com> wrote:
>ka@socrates.hr.att.com (Kenneth Almquist) writes:
>> I'm surprises that David Chase isn't familiar with compilers which
>> take advantage of the permission to evaluate arguments in arbitrary
>> order in order to generate better code. The basic idea is [Sethi-Ullman
>> numbering].
>> ... This idea is not new; the first two compilers for C (the Ritchie
>> compiler and PCC) both used it [or something similar].
>> So in the absence of register windows (which seem to have fallen out
>> of favor) requiring left-to-right evaluation will force a compiler


>Sadly enough, no compiler that I know of actually generates "optimal"
>code, for a variety of reasons (*). This one little frob is unlikely
>to make a difference that anyone would usually notice (though I, too,
>lack measurements to back this up), and if it did, those users who
>care would detect it when they profile their code (if they don't
>profile, they don't really care) and fix the order of evaluation
>manually. Therefore, all that is really lost is the automatic
>application of this apparently-minor optimization, and what is gained
>is portable, reproducible behavior.


--


Post a followup to this message

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