Newsgroups: | comp.compilers |
From: | hbaker@netcom.com (Henry Baker) |
Keywords: | C++, optimize |
Organization: | nil organization |
References: | 95-08-034 95-08-116 |
Date: | Mon, 21 Aug 1995 00:00:05 GMT |
sethml@sloth.ugcs.caltech.edu (Seth LaForge) wrote:
> Paul Eggert <eggert@twinsun.com> wrote:
> >In my opinion, order-of-evaluation is the most important problem
> >area in the C Standard proper. Other language standards since Algol 68
> >(e.g. Ada, Fortran, PL/I, Scheme) have addressed this issue more clearly.
> >Future C and C++ standards should do so as well.
>
> I don't know about the others, but the Scheme standard (The Revised ^
> 4 Report on the Algorithmic Language Scheme) states very clearly in
> section 4.1.3 (Procedure Calls) that, as in C, evaluation order is
> undefined.
>
> I think undefined order of evaluation makes all the sense in the
> world. Clearly no one order of evaluation is best; as someone's
> mentioned here, some optimizers will even change the order of
> evaluation within a program. I don't think it's worth constraining
> optimization for dubious gain.
>
> Also, backward compatibility is a serious problem. If anyone starts
> writing code that depends on order of evaluation, then it will not be
> portable to any existing compiler.
>
> I do very much like the idea of a compiler flag to specify evaluation
> order for debugging purposes. Any gcc implementors out there?
Since I started this thread, I have noticed that it has veered considerably
off course. The major issue I was addressing was not whether the multiple
arguments in a function call were evaluated in a left-to-right fashion versus
a right-to-left fashion, but whether they were evaluated in some _depth-first_
fashion versus some _breadth-first_ (or other) ordering.
Although I agree with David Chase that the issue of left-to-right v.
right-to-left is silly, I was willing to punt on that particular issue.
However, if I have to worry about various breadth-first or other non-depth
first orderings, then things get _a lot_ more complicated. In particular,
one has to start worrying about _locking_ between the multiple 'threads'
of the various argument expressions.
You've never done this, and you don't think it is a problem?? This only
indicates that you haven't read the language standards and don't realize that
your programs are at risk.
--
www/ftp directory:
ftp://ftp.netcom.com/pub/hb/hbaker/home.html
--
Return to the
comp.compilers page.
Search the
comp.compilers archives again.