home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!noc.near.net!hri.com!ukma!netnews.louisville.edu!starbase.spd.louisville.edu!aldavi01
- From: aldavi01@romulus.spd.louisville.edu (Arlie Davis)
- Newsgroups: comp.lang.c++
- Subject: Re: Answers on a postcard...
- Message-ID: <aldavi01.716489561@starbase.spd.louisville.edu>
- Date: 14 Sep 92 16:52:41 GMT
- References: <1992Sep11.174716.3699@taumet.com> <92256.150512KKEYTE@ESOC.BITNET> <1992Sep13.160033.7735@taumet.com> <1992Sep13.204500.16311@tfs.com>
- Sender: news@netnews.louisville.edu (Netnews)
- Organization: University of Louisville
- Lines: 52
- Nntp-Posting-Host: romulus.spd.louisville.edu
-
- In <1992Sep13.204500.16311@tfs.com> eric@tfs.com (Eric Smith) writes:
-
- > In article <1992Sep13.160033.7735@taumet.com> steve@taumet.com (Steve Clamage) writes:
- > ...
- > >It would be possible to change the rules so that order of evaluation
- > >was preserved for overloaded versions of operators "&&", "||", and ",".
- > >Any proposal to do so would have to show some good reason why the
-
- > Why not just require all function arguments to always be evaluated left
- > to right? That would simplify the language, shorten its description,
- > make it easier for novices to learn, and would not break any existing
- > bug-free code. I never did understand the value of leaving such
- > questions open, which accomplishes nothing useful and makes bugs
- > behave differently with different compilers.
-
- NO. From what I understand, the things in the ANSI C standard and in
- the ARM that are left undefined are done so to allow different
- architectures to compile and run C in the fastest / best manner
- possible, while still conforming to the standard.
-
- If you require / define something, such as the sequence of evaluation
- for parameters of a function call, you potentially require some
- compiler X for some machine Y to go to extremes in order to remain
- conformant with the standard. With the problem above, you might have
- one environment in which function calls were fastest when the
- first parameters were pushed first, but on another machine with a
- completely different environment pushing the last parameters first
- makes the most sense. (I have never heard of an environment which
- evaluates / pushes function args in forward order, but who knows.)
- On some architectures, function arguments may be evaluated
- simultaneously!
-
- So, if you rigidly define the sequence of evaluation, you potentially
- wound many C compilers + architectures. Same goes for many other
- things that are marked "undefined" or "architecture dependent".
- (I remember a debate on the remainder operator, in which some people
- wanted to define the result of the remainder operator for negative
- operands. Someone pointed out that the native assembler instruction
- for remainder varies from architecture to architecture, and that
- requiring all C compilers to return the same value for negative
- operands for remainder would mean that *many* compilers would have to
- generate many more opcodes in order to satisfy the standard.)
-
- Even if all the architectures that we *ever* used did everything in
- the same way ( ;) ), I would still want some of the things in ANSI C
- / the ARM left undefined, because relying on them encourages poor
- programming practice, in my opinion. Example: Using post-increment
- on the same variable twice in the same expression.
-
-
- --
- lrwx------ 1 aldavi01 emacsstu 9 Jun 6 12:43 .signature -> /dev/null
-