Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #16806 > unrolled thread

what is the right value about a = a++;

Started bylujnan <lujnan@gmail.com>
First post2012-02-06 00:10 -0800
Last post2012-02-07 01:18 -0500
Articles 20 on this page of 114 — 30 participants

Back to article view | Back to comp.lang.c


Contents

  what is the right value about  a = a++; lujnan <lujnan@gmail.com> - 2012-02-06 00:10 -0800
    Re: what is the right value about a = a++; Ruben Mikkonen <camu.umac@gmail.com> - 2012-02-06 00:28 -0800
      Re: what is the right value about a = a++; Keith Thompson <kst-u@mib.org> - 2012-02-06 21:27 -0800
        Re: what is the right value about a = a++; Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2012-02-06 22:39 -0700
    Re: what is the right value about  a = a++; bert <bert.hutchings@btinternet.com> - 2012-02-06 01:45 -0800
      Re: what is the right value about a = a++; lujnan <lujnan@gmail.com> - 2012-02-06 02:33 -0800
        Re: what is the right value about a = a++; "christian.bau" <christian.bau@cbau.wanadoo.co.uk> - 2012-02-06 14:57 -0800
        Re: what is the right value about a = a++; Barry Schwarz <schwarzb@dqel.com> - 2012-02-06 22:50 -0800
          Re: what is the right value about a = a++; Kaz Kylheku <kaz@kylheku.com> - 2012-02-07 08:15 +0000
            Re: what is the right value about a = a++; lujnan <lujnan@gmail.com> - 2012-02-07 00:31 -0800
              Re: what is the right value about a = a++; Keith Thompson <kst-u@mib.org> - 2012-02-07 09:07 -0800
                Re: what is the right value about a = a++; Kaz Kylheku <kaz@kylheku.com> - 2012-02-07 17:31 +0000
                  Re: what is the right value about a = a++; Joshua Maurice <joshuamaurice@gmail.com> - 2012-02-09 17:50 -0800
                  Re: what is the right value about a = a++; Phil Carmody <thefatphil_demunged@yahoo.co.uk> - 2012-02-21 23:42 +0200
                    Re: what is the right value about a = a++; Kaz Kylheku <kaz@kylheku.com> - 2012-02-22 04:28 +0000
                      Re: what is the right value about a = a++; Phil Carmody <thefatphil_demunged@yahoo.co.uk> - 2012-02-25 00:01 +0200
                      Re: what is the right value about a = a++; Shao Miller <sha0.miller@gmail.com> - 2012-02-25 02:25 -0500
                        Re: what is the right value about a = a++; Ike Naar <ike@iceland.freeshell.org> - 2012-02-25 09:00 +0000
                          Re: what is the right value about a = a++; Philip Lantz <prl@canterey.us> - 2012-02-25 11:13 -0800
                            Re: what is the right value about a = a++; cri@tiac.net (Richard Harter) - 2012-02-25 19:34 +0000
                              Re: what is the right value about a = a++; Kenneth Brody <kenbrody@spamcop.net> - 2012-02-25 16:51 -0500
                          Re: what is the right value about a = a++; lawrence.jones@siemens.com - 2012-02-27 16:12 -0500
                            Re: what is the right value about a = a++; Ike Naar <ike@iceland.freeshell.org> - 2012-02-27 22:42 +0000
                              Re: what is the right value about a = a++; Shao Miller <sha0.miller@gmail.com> - 2012-02-27 18:54 -0500
              Re: what is the right value about a = a++; Barry Schwarz <schwarzb@dqel.com> - 2012-02-07 09:26 -0800
            Re: what is the right value about a = a++; Kenneth Brody <kenbrody@spamcop.net> - 2012-02-07 15:12 -0500
              Re: what is the right value about a = a++; cri@tiac.net (Richard Harter) - 2012-02-07 21:50 +0000
                Re: what is the right value about a = a++; Stephen Sprunk <stephen@sprunk.org> - 2012-02-07 16:51 -0600
                  Re: what is the right value about a = a++; Robert Wessel <robertwessel2@yahoo.com> - 2012-02-07 22:49 -0600
                    Re: what is the right value about a = a++; Stephen Sprunk <stephen@sprunk.org> - 2012-02-08 14:08 -0600
                      Re: what is the right value about a = a++; Kaz Kylheku <kaz@kylheku.com> - 2012-02-09 00:18 +0000
                        Re: what is the right value about a = a++; Kenneth Brody <kenbrody@spamcop.net> - 2012-02-09 13:06 -0500
                          Re: what is the right value about a = a++; Stephen Sprunk <stephen@sprunk.org> - 2012-02-09 13:58 -0600
                          Re: what is the right value about a = a++; Kaz Kylheku <kaz@kylheku.com> - 2012-02-09 23:52 +0000
                          Re: what is the right value about a = a++; jgk@panix.com (Joe keane) - 2012-02-10 21:45 +0000
                            Re: what is the right value about a = a++; Phil Carmody <thefatphil_demunged@yahoo.co.uk> - 2012-02-22 00:09 +0200
                      Re: what is the right value about a = a++; Robert Wessel <robertwessel2@yahoo.com> - 2012-02-08 22:35 -0600
                    Re: what is the right value about a = a++; Kenneth Brody <kenbrody@spamcop.net> - 2012-02-08 15:42 -0500
                  Re: what is the right value about a = a++; cri@tiac.net (Richard Harter) - 2012-02-08 14:47 +0000
                    Re: what is the right value about a = a++; Stephen Sprunk <stephen@sprunk.org> - 2012-02-08 14:29 -0600
                      Re: what is the right value about a = a++; cri@tiac.net (Richard Harter) - 2012-02-10 02:27 +0000
                        Re: what is the right value about a = a++; James Kuyper <jameskuyper@verizon.net> - 2012-02-09 23:10 -0500
                          Re: what is the right value about a = a++; cri@tiac.net (Richard Harter) - 2012-02-10 09:11 +0000
                            Re: what is the right value about a = a++; James Kuyper <jameskuyper@verizon.net> - 2012-02-10 07:26 -0500
                              Re: what is the right value about a = a++; Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-02-10 13:12 +0000
                                Re: what is the right value about a = a++; James Kuyper <jameskuyper@verizon.net> - 2012-02-10 11:07 -0500
                              Re: what is the right value about a = a++; cri@tiac.net (Richard Harter) - 2012-02-10 16:27 +0000
                                Re: what is the right value about a = a++; James Kuyper <jameskuyper@verizon.net> - 2012-02-10 12:17 -0500
                                  Re: what is the right value about a = a++; Stephen Sprunk <stephen@sprunk.org> - 2012-02-10 12:09 -0600
                                    Re: what is the right value about a = a++; Kenneth Brody <kenbrody@spamcop.net> - 2012-02-10 18:17 -0500
                                      Re: what is the right value about a = a++; Kaz Kylheku <kaz@kylheku.com> - 2012-02-11 10:15 +0000
                                        Re: what is the right value about a = a++; Kenneth Brody <kenbrody@spamcop.net> - 2012-02-13 16:04 -0500
                        Re: what is the right value about a = a++; Stephen Sprunk <stephen@sprunk.org> - 2012-02-10 12:30 -0600
                    Re: what is the right value about a = a++; Shao Miller <sha0.miller@gmail.com> - 2012-02-09 21:30 -0500
                      Re: what is the right value about a = a++; cri@tiac.net (Richard Harter) - 2012-02-10 02:48 +0000
                        Re: what is the right value about a = a++; Kaz Kylheku <kaz@kylheku.com> - 2012-02-10 09:49 +0000
                  Re: what is the right value about a = a++; Kaz Kylheku <kaz@kylheku.com> - 2012-02-09 00:15 +0000
                    Re: what is the right value about a = a++; Kenneth Brody <kenbrody@spamcop.net> - 2012-02-09 12:49 -0500
                      Re: what is the right value about a = a++; Kaz Kylheku <kaz@kylheku.com> - 2012-02-09 23:51 +0000
                Re: what is the right value about a = a++; Kenneth Brody <kenbrody@spamcop.net> - 2012-02-08 15:39 -0500
                  Re: what is the right value about a = a++; Kaz Kylheku <kaz@kylheku.com> - 2012-02-09 01:05 +0000
                    Re: what is the right value about a = a++; Shao Miller <sha0.miller@gmail.com> - 2012-02-09 23:24 -0500
                      Re: what is the right value about a = a++; Jens Gustedt <jens.gustedt@loria.fr> - 2012-02-10 16:58 +0100
                        Re: what is the right value about a = a++; Kaz Kylheku <kaz@kylheku.com> - 2012-02-10 23:32 +0000
                  Re: what is the right value about a = a++; John Bode <jfbode1029@gmail.com> - 2012-02-08 17:41 -0800
                    Re: what is the right value about a = a++; James Kuyper <jameskuyper@verizon.net> - 2012-02-08 22:25 -0500
                    Re: what is the right value about a = a++; Kenneth Brody <kenbrody@spamcop.net> - 2012-02-09 13:15 -0500
                      Re: what is the right value about a = a++; Kaz Kylheku <kaz@kylheku.com> - 2012-02-09 23:57 +0000
                        Re: what is the right value about a = a++; Kenneth Brody <kenbrody@spamcop.net> - 2012-02-10 11:15 -0500
                          Re: what is the right value about a = a++; Stephen Sprunk <stephen@sprunk.org> - 2012-02-10 11:58 -0600
                            Re: what is the right value about a = a++; Kenneth Brody <kenbrody@spamcop.net> - 2012-02-10 18:14 -0500
                          Re: what is the right value about a = a++; Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-02-10 22:43 +0000
                        Re: what is the right value about a = a++; Stephen Sprunk <stephen@sprunk.org> - 2012-02-10 11:53 -0600
                        Re: what is the right value about a = a++; Joshua Maurice <joshuamaurice@gmail.com> - 2012-02-10 15:19 -0800
                  Re: what is the right value about a = a++; cri@tiac.net (Richard Harter) - 2012-02-10 02:32 +0000
                    Re: what is the right value about a = a++; James Kuyper <jameskuyper@verizon.net> - 2012-02-09 23:13 -0500
                      Re: what is the right value about a = a++; cri@tiac.net (Richard Harter) - 2012-02-10 09:34 +0000
                        Re: what is the right value about a = a++; James Kuyper <jameskuyper@verizon.net> - 2012-02-10 07:32 -0500
                          Re: what is the right value about a = a++; Kaz Kylheku <kaz@kylheku.com> - 2012-02-10 22:24 +0000
                        Re: what is the right value about a = a++; Kenneth Brody <kenbrody@spamcop.net> - 2012-02-10 11:35 -0500
                          Re: what is the right value about a = a++; James Kuyper <jameskuyper@verizon.net> - 2012-02-10 12:23 -0500
                Re: what is the right value about a = a++; falk@rahul.net (Edward A. Falk) - 2012-02-08 20:40 +0000
                  Re: what is the right value about a = a++; Keith Thompson <kst-u@mib.org> - 2012-02-08 15:00 -0800
                  Re: what is the right value about a = a++; Kaz Kylheku <kaz@kylheku.com> - 2012-02-09 01:10 +0000
                    Re: what is the right value about a = a++; 88888 Dihedral <dihedral88888@googlemail.com> - 2012-02-09 20:43 -0800
                      Re: what is the right value about a = a++; Robert Wessel <robertwessel2@yahoo.com> - 2012-02-09 23:36 -0600
                  Re: what is the right value about a = a++; cri@tiac.net (Richard Harter) - 2012-02-10 02:40 +0000
                    Re: what is the right value about a = a++; James Kuyper <jameskuyper@verizon.net> - 2012-02-09 23:17 -0500
                Re: what is the right value about a = a++; Kaz Kylheku <kaz@kylheku.com> - 2012-02-08 23:49 +0000
              Re: what is the right value about a = a++; Kaz Kylheku <kaz@kylheku.com> - 2012-02-08 23:42 +0000
            Re: what is the right value about a = a++; blp@cs.stanford.edu (Ben Pfaff) - 2012-02-07 12:09 -0800
        Re: what is the right value about a = a++; James Kuyper <jameskuyper@verizon.net> - 2012-02-07 07:42 -0500
          Re: what is the right value about a = a++; Kaz Kylheku <kaz@kylheku.com> - 2012-02-07 17:21 +0000
            Re: what is the right value about a = a++; Stephen Sprunk <stephen@sprunk.org> - 2012-02-07 15:24 -0600
              Re: what is the right value about a = a++; Kaz Kylheku <kaz@kylheku.com> - 2012-02-09 01:27 +0000
                Re: what is the right value about a = a++; Stephen Sprunk <stephen@sprunk.org> - 2012-02-10 21:57 -0600
        Re: what is the right value about a = a++; "Joel C. Salomon" <joelcsalomon@gmail.com> - 2012-02-08 01:00 -0500
        Re: what is the right value about a = a++; falk@rahul.net (Edward A. Falk) - 2012-02-08 20:33 +0000
          Re: what is the right value about a = a++; Kaz Kylheku <kaz@kylheku.com> - 2012-02-09 02:05 +0000
      Re: what is the right value about  a = a++; Markus Wichmann <nullplan@gmx.net> - 2012-02-09 09:28 +0100
        Re: what is the right value about  a = a++; Kaz Kylheku <kaz@kylheku.com> - 2012-02-09 10:21 +0000
          Re: what is the right value about  a = a++; Kaz Kylheku <kaz@kylheku.com> - 2012-02-09 11:38 +0000
          Re: what is the right value about  a = a++; Shao Miller <sha0.miller@gmail.com> - 2012-02-10 00:03 -0500
          Re: what is the right value about  a = a++; Philip Lantz <prl@canterey.us> - 2012-02-10 01:15 -0800
        Re: what is the right value about  a = a++; Kenneth Brody <kenbrody@spamcop.net> - 2012-02-09 13:22 -0500
    Re: what is the right value about a = a++; Slash QB <slashqb@gmail.com> - 2012-02-06 02:35 -0800
      Re: what is the right value about a = a++; Nick Keighley <nick_keighley_nospam@hotmail.com> - 2012-02-07 03:07 -0800
        Re: what is the right value about a = a++; Stephen Sprunk <stephen@sprunk.org> - 2012-02-07 15:19 -0600
          Re: what is the right value about a = a++; James Kuyper <jameskuyper@verizon.net> - 2012-02-07 17:00 -0500
            Re: what is the right value about a = a++; Stephen Sprunk <stephen@sprunk.org> - 2012-02-10 12:05 -0600
              Re: what is the right value about a = a++; James Kuyper <jameskuyper@verizon.net> - 2012-02-10 13:46 -0500
    Re: what is the right value about  a = a++; Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2012-02-06 22:37 -0700
      Re: what is the right value about  a = a++; Kaz Kylheku <kaz@kylheku.com> - 2012-02-07 07:22 +0000
    Re: what is the right value about  a = a++; Shao Miller <sha0.miller@gmail.com> - 2012-02-07 01:18 -0500

Page 3 of 6 — ← Prev page 1 2 [3] 4 5 6  Next page →


#17025 — Re: what is the right value about a = a++;

Fromcri@tiac.net (Richard Harter)
Date2012-02-10 02:27 +0000
SubjectRe: what is the right value about a = a++;
Message-ID<4f347b72.423614568@text.giganews.com>
In reply to#16940
On Wed, 08 Feb 2012 14:29:05 -0600, Stephen Sprunk
<stephen@sprunk.org> wrote:

>On 08-Feb-12 08:47, Richard Harter wrote:
>> On Tue, 07 Feb 2012 16:51:17 -0600, Stephen Sprunk
>> <stephen@sprunk.org> wrote:
>> 
>>> On 07-Feb-12 15:50, Richard Harter wrote:
>>>> On Tue, 07 Feb 2012 15:12:53 -0500, Kenneth Brody
>>>> <kenbrody@spamcop.net> wrote:
>>>>> On 2/7/2012 3:15 AM, Kaz Kylheku wrote:
>>>>>> I don't want diagnostics; I want strict left to right evaluation order
>>>>>> of operands and subexpressions that complete their side effects before
>>>>>> yielding a value.
>>>>>
>>>>> So, what you are really saying, is you want to eliminate most of C's 
>>>>> optimization abilities, by restricting the order in which the expression 
>>>>> *must* be evaluated, and side effects *must* be completed?
>>>>
>>>> Well, no, he isn't saying any such thing.  You just made it up.  The
>>>> fact that evaluation order in C is left to the compilers has very
>>>> little to do with optimization; it is a historical artifact that came
>>>> from endorsing existing practice when the ANSI standard was put
>>>> together.  Existing practice then was that compiler writers could do
>>>> evaluations in whatever they pleased and they did.
>>>
>>> No, they did evaluations in the order that made the most sense (i.e. had
>>> the best performance) for their particular implementation--and
>>> implementations vary.
>> 
>> You are not disagreeing with me.
>
>I disagree that they did "whatever they pleased"; they did what was best
>for their particular implementation, for various definitions of "best".

Then if they did whatever they thought was best then that was what
they pleased.  I'm not sure what you think "whatever they pleased"
means. 
>
>>> For instance, varargs is more straightforward to implement with
>>> right-to-left evaluation of arguments, at least with a stack-based
>>> calling convention.  Order of evaluation may not matter for
>>> register-based calling conventions, but if an implementation uses both,
>>> it makes sense to use the same order.
>> 
>> Well, yes, I know that.  However what you are talking about is a minor
>> micro-optimization at most.
>
>It doesn't seem so minor, particularly for platforms where _every_ call
>uses a stack-based calling convention.

Whoa.  The claim was about the cost of implementing varargs, something
only used in a rather small number of cases.  For that matter, at the
time varargs was not standardized.  Optimizing processing varargs was
and is a micro-optimization, then and now.   

>Remember, we're talking about
>long ago when compilers were rather dumb and most popular architectures
>were register-starved.

Granted.  And it is also true that the generated code in the bodies of
functions also suffered both because the architectures were limited
and, quite bluntly, the quality of most implementations were limited.
Furthermore evaluating function arguments right to left rather than
left to right is an almost imperceptible micro-optimization when it is
an optimization at all.  

>That is the environment that ANSI was faced
>with, and it would have been unreasonable to force the majority of
>implementations to suffer a performance penalty for the questionable
>benefit of left-to-right evaluation.

IMNSHO that performance penalty is much more fantasy than reality.  On
the other hand the cost of reworking all of those compilers was a very
real cost.  Quite reasonably, nobody wanted to pay that price.

On the other hand there is a real benefit when all behaviours are well
defined, when all code is either legal or illegal, and what the code
is supposed to do can be determined by inspection of the code.  The
qualility of C as a language would IMO be enhanced if most of these
"undefined behaviours" were compilation errors.






>
>> Historically the variations weren't a matter of performance - for the
>> most part the performance of the early compilers was less than
>> stellar.
>
>Of course; that was the state of the industry at the time.  All the more
>reason not to make things worse.
>
>> The various choices in calling sequence conventions and in
>> parsing order were a mixture of convenience and ad hoc decisions.  The
>> order variations were an unalterable part of the language by the time
>> it came to standardization.
>
>I think we can agree on this much: by the time ANSI looked at the
>matter, it was too late to "fix" many of the behaviors that ended up
>being called undefined, unspecified or implementation-defined because
>doing so would have broken a lot of code that implicitly depended on a
>particular implementation's pre-standard behavior.
>
>> In any event the idea that "most of C's optimization abilities" depend
>> upon not restricting evaluation order and side effect order is a wild
>> exaggeration.
>
>Optimization doesn't depend entirely on that particular gray area, but
>gray areas in general provide implementations leeway to make more
>aggressive optimizations because they lessen the impact of the "as if"
>rule.  Allowing the meaning of "a=a++;" to change isn't helpful in
>itself, but it may help the compiler optimize _something else_.
>
>Also, most of those gray areas aren't terribly useful in the first place
>and avoiding them generally results in clearer code anyway.  If _I_
>can't figure out what "a=a++;" is supposed to mean, without possibly
>resorting to the Standard, it's not important to me that the compiler
>knows either because I won't write it in the first place!  My primary
>audience is human, not machine.
>
>S
>
>-- 
>Stephen Sprunk         "God does not play dice."  --Albert Einstein
>CCIE #3723         "God is an inveterate gambler, and He throws the
>K5SSS        dice at every possible opportunity." --Stephen Hawking

[toc] | [prev] | [next] | [standalone]


#17030 — Re: what is the right value about a = a++;

FromJames Kuyper <jameskuyper@verizon.net>
Date2012-02-09 23:10 -0500
SubjectRe: what is the right value about a = a++;
Message-ID<jh25c7$3sk$1@dont-email.me>
In reply to#17025
On 02/09/2012 09:27 PM, Richard Harter wrote:
> On Wed, 08 Feb 2012 14:29:05 -0600, Stephen Sprunk
> <stephen@sprunk.org> wrote:
> 
>> On 08-Feb-12 08:47, Richard Harter wrote:
>>> On Tue, 07 Feb 2012 16:51:17 -0600, Stephen Sprunk
>>> <stephen@sprunk.org> wrote:
>>>
>>>> On 07-Feb-12 15:50, Richard Harter wrote:
...
>>>>> together.  Existing practice then was that compiler writers could do
>>>>> evaluations in whatever they pleased and they did.
>>>>
>>>> No, they did evaluations in the order that made the most sense (i.e. had
>>>> the best performance) for their particular implementation--and
>>>> implementations vary.
>>>
>>> You are not disagreeing with me.
>>
>> I disagree that they did "whatever they pleased"; they did what was best
>> for their particular implementation, for various definitions of "best".
> 
> Then if they did whatever they thought was best then that was what
> they pleased.  I'm not sure what you think "whatever they pleased"
> means.

"What they thought was best" is not, in general, the same as "What
pleased them most". For instance, for some implementors, it might have
pleased them most to insert warning messages that made fun of people
whose politics they disagreed with. But what they thought was best
probably didn't include losing that portion of their potential market
which would have been offended by such messages, nor that additional
share of their potential market that might have felt that such warning
messages showed insufficient professionalism.

I tried to come up with an example that more directly applies the
evaluation order of operands, but I had a hard time coming up with any
plausible examples where "pleasure" could be a significant issue.
Efficiency, ease of implementation, compatibility with other
implementations - I can see them all as being relevant, but I couldn't
figure out how to bring "pleasure" in to the mix for evaluation order
issues.
-- 
James Kuyper

[toc] | [prev] | [next] | [standalone]


#17043 — Re: what is the right value about a = a++;

Fromcri@tiac.net (Richard Harter)
Date2012-02-10 09:11 +0000
SubjectRe: what is the right value about a = a++;
Message-ID<4f34de13.448865592@text.giganews.com>
In reply to#17030
On Thu, 09 Feb 2012 23:10:46 -0500, James Kuyper
<jameskuyper@verizon.net> wrote:

>On 02/09/2012 09:27 PM, Richard Harter wrote:
>> On Wed, 08 Feb 2012 14:29:05 -0600, Stephen Sprunk
>> <stephen@sprunk.org> wrote:
>> 
>>> On 08-Feb-12 08:47, Richard Harter wrote:
>>>> On Tue, 07 Feb 2012 16:51:17 -0600, Stephen Sprunk
>>>> <stephen@sprunk.org> wrote:
>>>>
>>>>> On 07-Feb-12 15:50, Richard Harter wrote:
>...
>>>>>> together.  Existing practice then was that compiler writers could do
>>>>>> evaluations in whatever they pleased and they did.
>>>>>
>>>>> No, they did evaluations in the order that made the most sense (i.e. had
>>>>> the best performance) for their particular implementation--and
>>>>> implementations vary.
>>>>
>>>> You are not disagreeing with me.
>>>
>>> I disagree that they did "whatever they pleased"; they did what was best
>>> for their particular implementation, for various definitions of "best".
>> 
>> Then if they did whatever they thought was best then that was what
>> they pleased.  I'm not sure what you think "whatever they pleased"
>> means.
>
>"What they thought was best" is not, in general, the same as "What
>pleased them most". 

Stop right there. "whatever they pleased" and "What pleased them most"
are two different things. 

[snip irrelevant remainder even though it is interesting]

[toc] | [prev] | [next] | [standalone]


#17050 — Re: what is the right value about a = a++;

FromJames Kuyper <jameskuyper@verizon.net>
Date2012-02-10 07:26 -0500
SubjectRe: what is the right value about a = a++;
Message-ID<jh32da$2ec$1@dont-email.me>
In reply to#17043
On 02/10/2012 04:11 AM, Richard Harter wrote:
> On Thu, 09 Feb 2012 23:10:46 -0500, James Kuyper
> <jameskuyper@verizon.net> wrote:
...
>> "What they thought was best" is not, in general, the same as "What
>> pleased them most". 
> 
> Stop right there. "whatever they pleased" and "What pleased them most"
> are two different things. 

True - and yet, if you took every occurrence of "what pleased them
most", or variations of the same, from my message, and replace it with a
corresponding variation on "whatever they pleased", the message would
remain equally true.
-- 
James Kuyper

[toc] | [prev] | [next] | [standalone]


#17052 — Re: what is the right value about a = a++;

FromBen Bacarisse <ben.usenet@bsb.me.uk>
Date2012-02-10 13:12 +0000
SubjectRe: what is the right value about a = a++;
Message-ID<0.d4b1cf7ce131b4663689.20120210131236GMT.87obt6de7v.fsf@bsb.me.uk>
In reply to#17050
James Kuyper <jameskuyper@verizon.net> writes:

> On 02/10/2012 04:11 AM, Richard Harter wrote:
>> On Thu, 09 Feb 2012 23:10:46 -0500, James Kuyper
>> <jameskuyper@verizon.net> wrote:
> ...
>>> "What they thought was best" is not, in general, the same as "What
>>> pleased them most". 
>> 
>> Stop right there. "whatever they pleased" and "What pleased them most"
>> are two different things. 
>
> True - and yet, if you took every occurrence of "what pleased them
> most", or variations of the same, from my message, and replace it with a
> corresponding variation on "whatever they pleased", the message would
> remain equally true.

I can't make that work.  Your usage emphasises (explicitly) the idea of
pleasure being involved, and that is surely the difference Richard
Harter is pointing out.  "What pleased them most" is about pleasure and
gratification, but "whatever they please" is about having "the will or
desire; to have the inclination or disposition; to think proper; to
choose" (though having pleasure in the result is not excluded, of
course).

-- 
Ben.

[toc] | [prev] | [next] | [standalone]


#17055 — Re: what is the right value about a = a++;

FromJames Kuyper <jameskuyper@verizon.net>
Date2012-02-10 11:07 -0500
SubjectRe: what is the right value about a = a++;
Message-ID<4F3540D0.5040205@verizon.net>
In reply to#17052
On 02/10/2012 08:12 AM, Ben Bacarisse wrote:
> James Kuyper <jameskuyper@verizon.net> writes:
> 
>> On 02/10/2012 04:11 AM, Richard Harter wrote:
>>> On Thu, 09 Feb 2012 23:10:46 -0500, James Kuyper
>>> <jameskuyper@verizon.net> wrote:
>> ...
>>>> "What they thought was best" is not, in general, the same as "What
>>>> pleased them most". 
>>>
>>> Stop right there. "whatever they pleased" and "What pleased them most"
>>> are two different things. 
>>
>> True - and yet, if you took every occurrence of "what pleased them
>> most", or variations of the same, from my message, and replace it with a
>> corresponding variation on "whatever they pleased", the message would
>> remain equally true.
> 
> I can't make that work.  Your usage emphasises (explicitly) the idea of
> pleasure being involved, and that is surely the difference Richard
> Harter is pointing out.  "What pleased them most" is about pleasure and
> gratification, but "whatever they please" is about having "the will or
> desire; to have the inclination or disposition; to think proper; to
> choose" (though having pleasure in the result is not excluded, of
> course).

I think that any interpretation of "whatever they please" that doesn't
connect to the concept of pleasure is somewhat odd, but it's not really
a problem for what I was saying. The key point of what I wrote was that
"whatever they please" is different from "what they thought was best";
the details of how they differ are less important than the fact of a
difference.

It's not exactly an unusual thing for people to have the will, desire,
inclination or disposition to do something other than what they think is
best.  It's not even usual for people to actually choose to do something
other than what they think best.

[toc] | [prev] | [next] | [standalone]


#17057 — Re: what is the right value about a = a++;

Fromcri@tiac.net (Richard Harter)
Date2012-02-10 16:27 +0000
SubjectRe: what is the right value about a = a++;
Message-ID<4f353e9c.473579192@text.giganews.com>
In reply to#17050
On Fri, 10 Feb 2012 07:26:17 -0500, James Kuyper
<jameskuyper@verizon.net> wrote:

>On 02/10/2012 04:11 AM, Richard Harter wrote:
>> On Thu, 09 Feb 2012 23:10:46 -0500, James Kuyper
>> <jameskuyper@verizon.net> wrote:
>...
>>> "What they thought was best" is not, in general, the same as "What
>>> pleased them most". 
>> 
>> Stop right there. "whatever they pleased" and "What pleased them most"
>> are two different things. 
>
>True - and yet, if you took every occurrence of "what pleased them
>most", or variations of the same, from my message, and replace it with a
>corresponding variation on "whatever they pleased", the message would
>remain equally true.

I agree with Ben; it doesn't work, though you might give it a try.  If
you do, start with "whatever they chanced to do" or something similar.

That said, the point you made is quite valid. What I was getting at,
though, is that without the constraint of a standard or something
implementation choices have an element of caprice and arbitrariness.  

[toc] | [prev] | [next] | [standalone]


#17063 — Re: what is the right value about a = a++;

FromJames Kuyper <jameskuyper@verizon.net>
Date2012-02-10 12:17 -0500
SubjectRe: what is the right value about a = a++;
Message-ID<4F355114.1000504@verizon.net>
In reply to#17057
On 02/10/2012 11:27 AM, Richard Harter wrote:
> On Fri, 10 Feb 2012 07:26:17 -0500, James Kuyper
> <jameskuyper@verizon.net> wrote:
> 
>> On 02/10/2012 04:11 AM, Richard Harter wrote:
>>> On Thu, 09 Feb 2012 23:10:46 -0500, James Kuyper
>>> <jameskuyper@verizon.net> wrote:
>> ...
>>>> "What they thought was best" is not, in general, the same as "What
>>>> pleased them most". 
>>>
>>> Stop right there. "whatever they pleased" and "What pleased them most"
>>> are two different things. 
>>
>> True - and yet, if you took every occurrence of "what pleased them
>> most", or variations of the same, from my message, and replace it with a
>> corresponding variation on "whatever they pleased", the message would
>> remain equally true.
> 
> I agree with Ben; it doesn't work, though you might give it a try.  If
> you do, start with "whatever they chanced to do" or something similar.

Here's the re-write; it wasn't quite as simple as I implied, but it's
still trivial:

"What they thought was best" is not, in general, the same as "What
they pleased". For instance, some implementers might have been
pleased to insert warning messages that made fun of people
whose politics they disagreed with. But what they thought was best
probably didn't include losing that portion of their potential market
which would have been offended by such messages, nor that additional
share of their potential market that might have felt that such warning
messages showed insufficient professionalism.

I tried to come up with an example that more directly applies the
evaluation order of operands, but I had a hard time coming up with any
plausible examples where an implementor might have been pleased to do
something other than what they thought best.

> That said, the point you made is quite valid. What I was getting at,
> though, is that without the constraint of a standard or something
> implementation choices have an element of caprice and arbitrariness.  

I don't think that element is a big one. Implementors who pay attention
to the needs of their customers tend to find their choices significantly
constrained by those needs, and so long as they work within those
constraints, they tend to have more customers than those implementers
who let caprice and arbitrariness rule their designs.

[toc] | [prev] | [next] | [standalone]


#17068 — Re: what is the right value about a = a++;

FromStephen Sprunk <stephen@sprunk.org>
Date2012-02-10 12:09 -0600
SubjectRe: what is the right value about a = a++;
Message-ID<jh3mgj$q9k$1@dont-email.me>
In reply to#17063
On 10-Feb-12 11:17, James Kuyper wrote:
> I tried to come up with an example that more directly applies the
> evaluation order of operands, but I had a hard time coming up with any
> plausible examples where an implementor might have been pleased to do
> something other than what they thought best.

Some implementor might have been pleased to evaluate function arguments
left-to-right, for cultural reasons, but found it was "better" to
evaluate them right-to-left.

S

-- 
Stephen Sprunk         "God does not play dice."  --Albert Einstein
CCIE #3723         "God is an inveterate gambler, and He throws the
K5SSS        dice at every possible opportunity." --Stephen Hawking

[toc] | [prev] | [next] | [standalone]


#17095 — Re: what is the right value about a = a++;

FromKenneth Brody <kenbrody@spamcop.net>
Date2012-02-10 18:17 -0500
SubjectRe: what is the right value about a = a++;
Message-ID<94OdncV-l6gROKjSnZ2dnUVZ_oednZ2d@bestweb.net>
In reply to#17068
On 2/10/2012 1:09 PM, Stephen Sprunk wrote:
> On 10-Feb-12 11:17, James Kuyper wrote:
>> I tried to come up with an example that more directly applies the
>> evaluation order of operands, but I had a hard time coming up with any
>> plausible examples where an implementor might have been pleased to do
>> something other than what they thought best.
>
> Some implementor might have been pleased to evaluate function arguments
> left-to-right, for cultural reasons, but found it was "better" to
> evaluate them right-to-left.

Hence the existence in some implementations of "extern pascal".  :-)

-- 
Kenneth Brody

[toc] | [prev] | [next] | [standalone]


#17108 — Re: what is the right value about a = a++;

FromKaz Kylheku <kaz@kylheku.com>
Date2012-02-11 10:15 +0000
SubjectRe: what is the right value about a = a++;
Message-ID<20120211021421.361@kylheku.com>
In reply to#17095
On 2012-02-10, Kenneth Brody <kenbrody@spamcop.net> wrote:
> On 2/10/2012 1:09 PM, Stephen Sprunk wrote:
>> On 10-Feb-12 11:17, James Kuyper wrote:
>>> I tried to come up with an example that more directly applies the
>>> evaluation order of operands, but I had a hard time coming up with any
>>> plausible examples where an implementor might have been pleased to do
>>> something other than what they thought best.
>>
>> Some implementor might have been pleased to evaluate function arguments
>> left-to-right, for cultural reasons, but found it was "better" to
>> evaluate them right-to-left.
>
> Hence the existence in some implementations of "extern pascal".  :-)

Order of argument evaluation is not calling convention.

extern pascal was needed to conform to a calling convention.

[toc] | [prev] | [next] | [standalone]


#17244 — Re: what is the right value about a = a++;

FromKenneth Brody <kenbrody@spamcop.net>
Date2012-02-13 16:04 -0500
SubjectRe: what is the right value about a = a++;
Message-ID<__qdnT4GoqZy56TSnZ2dnUVZ_rCdnZ2d@bestweb.net>
In reply to#17108
On 2/11/2012 5:15 AM, Kaz Kylheku wrote:
> On 2012-02-10, Kenneth Brody<kenbrody@spamcop.net>  wrote:
>> On 2/10/2012 1:09 PM, Stephen Sprunk wrote:
>>> On 10-Feb-12 11:17, James Kuyper wrote:
>>>> I tried to come up with an example that more directly applies the
>>>> evaluation order of operands, but I had a hard time coming up with any
>>>> plausible examples where an implementor might have been pleased to do
>>>> something other than what they thought best.
>>>
>>> Some implementor might have been pleased to evaluate function arguments
>>> left-to-right, for cultural reasons, but found it was "better" to
>>> evaluate them right-to-left.
>>
>> Hence the existence in some implementations of "extern pascal".  :-)
>
> Order of argument evaluation is not calling convention.
>
> extern pascal was needed to conform to a calling convention.

You are, of course, correct.  While an implementation _typically_ evaluates 
arguments in the order it puts them in place for the call (whether that's 
pushing onto a stack, loading registers, or something else), it's certainly 
not a guarantee.

-- 
Kenneth Brody

[toc] | [prev] | [next] | [standalone]


#17070 — Re: what is the right value about a = a++;

FromStephen Sprunk <stephen@sprunk.org>
Date2012-02-10 12:30 -0600
SubjectRe: what is the right value about a = a++;
Message-ID<jh3non$2h7$1@dont-email.me>
In reply to#17025
On 09-Feb-12 20:27, Richard Harter wrote:
> On Wed, 08 Feb 2012 14:29:05 -0600, Stephen Sprunk
> <stephen@sprunk.org> wrote:
>> On 08-Feb-12 08:47, Richard Harter wrote:
>>> On Tue, 07 Feb 2012 16:51:17 -0600, Stephen Sprunk
>>> <stephen@sprunk.org> wrote:
>>>> On 07-Feb-12 15:50, Richard Harter wrote:
>>>>> Well, no, he isn't saying any such thing.  You just made it up.  The
>>>>> fact that evaluation order in C is left to the compilers has very
>>>>> little to do with optimization; it is a historical artifact that came
>>>>> from endorsing existing practice when the ANSI standard was put
>>>>> together.  Existing practice then was that compiler writers could do
>>>>> evaluations in whatever they pleased and they did.
>>>>
>>>> No, they did evaluations in the order that made the most sense (i.e. had
>>>> the best performance) for their particular implementation--and
>>>> implementations vary.
>>>
>>> You are not disagreeing with me.
>>
>> I disagree that they did "whatever they pleased"; they did what was best
>> for their particular implementation, for various definitions of "best".
> 
> Then if they did whatever they thought was best then that was what
> they pleased.  I'm not sure what you think "whatever they pleased"
> means. 

There are a great many things that would please me but which are not the
"best" thing to do.

>>>> For instance, varargs is more straightforward to implement with
>>>> right-to-left evaluation of arguments, at least with a stack-based
>>>> calling convention.  Order of evaluation may not matter for
>>>> register-based calling conventions, but if an implementation uses both,
>>>> it makes sense to use the same order.
>>>
>>> Well, yes, I know that.  However what you are talking about is a minor
>>> micro-optimization at most.
>>
>> It doesn't seem so minor, particularly for platforms where _every_ call
>> uses a stack-based calling convention.
> 
> Whoa.  The claim was about the cost of implementing varargs, something
> only used in a rather small number of cases.  For that matter, at the
> time varargs was not standardized.  Optimizing processing varargs was
> and is a micro-optimization, then and now.   

True, but it would be perverse to have right-to-left evaluation for
varargs calls but left-to-right evaluation for non-varargs calls.

In fact, a similar perversity actually exists in the wild: Win16/32 API
calls are evaluated left-to-right because the API specifies a "Pascal"
(push onto stack from left to right) calling convention, but non-API
calls will use a "C" (push onto stack from right to left) calling
convention.  So, two consecutive function calls may have two different
orders of evaluation!

>> Remember, we're talking about
>> long ago when compilers were rather dumb and most popular architectures
>> were register-starved.
> 
> Granted.  And it is also true that the generated code in the bodies of
> functions also suffered both because the architectures were limited
> and, quite bluntly, the quality of most implementations were limited.
> Furthermore evaluating function arguments right to left rather than
> left to right is an almost imperceptible micro-optimization when it is
> an optimization at all.  

Adding a few cycles to _every_ function call would add up; computers
back then were slow enough as it was.

>> That is the environment that ANSI was faced
>> with, and it would have been unreasonable to force the majority of
>> implementations to suffer a performance penalty for the questionable
>> benefit of left-to-right evaluation.
> 
> IMNSHO that performance penalty is much more fantasy than reality.  On
> the other hand the cost of reworking all of those compilers was a very
> real cost.  Quite reasonably, nobody wanted to pay that price.

I'm sure that was factored in as well.  Plus, there was a large base of
code that may have _depended_ on a particular order of evaluation.  If
nothing else, it would have been impossible to prove there wasn't.

> On the other hand there is a real benefit when all behaviours are well
> defined, when all code is either legal or illegal, and what the code
> is supposed to do can be determined by inspection of the code.  The
> qualility of C as a language would IMO be enhanced if most of these
> "undefined behaviours" were compilation errors.

True, but that is a luxury of developing standards _before_ amassing a
huge codebase.  That's not how C developed.

S

-- 
Stephen Sprunk         "God does not play dice."  --Albert Einstein
CCIE #3723         "God is an inveterate gambler, and He throws the
K5SSS        dice at every possible opportunity." --Stephen Hawking

[toc] | [prev] | [next] | [standalone]


#17024 — Re: what is the right value about a = a++;

FromShao Miller <sha0.miller@gmail.com>
Date2012-02-09 21:30 -0500
SubjectRe: what is the right value about a = a++;
Message-ID<jh1v9s$97g$2@dont-email.me>
In reply to#16925
On 2/8/2012 09:47, Richard Harter wrote:
>
> It was one thing to say that C is what it is, so suck it up and deal
> with it.  It is quite
>

Your post was truncated?

[toc] | [prev] | [next] | [standalone]


#17028 — Re: what is the right value about a = a++;

Fromcri@tiac.net (Richard Harter)
Date2012-02-10 02:48 +0000
SubjectRe: what is the right value about a = a++;
Message-ID<4f348536.426114562@text.giganews.com>
In reply to#17024
On Thu, 09 Feb 2012 21:30:19 -0500, Shao Miller
<sha0.miller@gmail.com> wrote:

>On 2/8/2012 09:47, Richard Harter wrote:
>>
>> It was one thing to say that C is what it is, so suck it up and deal
>> with it.  It is quite
>>
>
>Your post was truncated?

Apparently.  The text I sent was:

Granted there is no point in whining about C's lack of a well defined
evaluation.  C is what it is and "undefined" is pretty much carved in
stone.  But it has very little to do with optimization and a lot to do
with "that's the way things are; suck it up cupcake and live with it."


[toc] | [prev] | [next] | [standalone]


#17047 — Re: what is the right value about a = a++;

FromKaz Kylheku <kaz@kylheku.com>
Date2012-02-10 09:49 +0000
SubjectRe: what is the right value about a = a++;
Message-ID<20120210014325.277@kylheku.com>
In reply to#17028
On 2012-02-10, Richard Harter <cri@tiac.net> wrote:
> On Thu, 09 Feb 2012 21:30:19 -0500, Shao Miller
><sha0.miller@gmail.com> wrote:
>
>>On 2/8/2012 09:47, Richard Harter wrote:
>>>
>>> It was one thing to say that C is what it is, so suck it up and deal
>>> with it.  It is quite
>>>
>>
>>Your post was truncated?
>
> Apparently.  The text I sent was:
>
> Granted there is no point in whining about C's lack of a well defined
> evaluation.

Nobody is "whining". I made a well-considered criticism.

C would be a better language without gratuitous behaviors in the way abstract
expressions are put together.

> C is what it is and "undefined" is pretty much carved in
> stone. 

C is obviously not carved in stone, which is why there are so many C's to
choose from.  K&RC, C90, C99, C11 ...

Once upon a time it might have been "whining" to want better type checking
between function declarations and definitions.

> But it has very little to do with optimization and a lot to do
> with "that's the way things are; suck it up cupcake and live with it."

That is neither here nor there.

However, I might just implement this strict evaluation in GCC one of these days
as an option.  That would be a good start to actually get it done.

However, there is value in discussing the idea, too.

[toc] | [prev] | [next] | [standalone]


#16954 — Re: what is the right value about a = a++;

FromKaz Kylheku <kaz@kylheku.com>
Date2012-02-09 00:15 +0000
SubjectRe: what is the right value about a = a++;
Message-ID<20120208160357.841@kylheku.com>
In reply to#16879
On 2012-02-07, Stephen Sprunk <stephen@sprunk.org> wrote:
> On 07-Feb-12 15:50, Richard Harter wrote:
>> On Tue, 07 Feb 2012 15:12:53 -0500, Kenneth Brody
>> <kenbrody@spamcop.net> wrote:
>>> On 2/7/2012 3:15 AM, Kaz Kylheku wrote:
>>>> I don't want diagnostics; I want strict left to right evaluation order
>>>> of operands and subexpressions that complete their side effects before
>>>> yielding a value.
>>>
>>> So, what you are really saying, is you want to eliminate most of C's 
>>> optimization abilities, by restricting the order in which the expression 
>>> *must* be evaluated, and side effects *must* be completed?
>> 
>> Well, no, he isn't saying any such thing.  You just made it up.  The
>> fact that evaluation order in C is left to the compilers has very
>> little to do with optimization; it is a historical artifact that came
>> from endorsing existing practice when the ANSI standard was put
>> together.  Existing practice then was that compiler writers could do
>> evaluations in whatever they pleased and they did.
>
> No, they did evaluations in the order that made the most sense (i.e. had
> the best performance) for their particular implementation--and
> implementations vary.

Old compilers had hard-coded syntax-directed translation behaviors that were
convenient for the implementor. For instance a function call could be
handled as a single unit emitting some boiler-plate expansion.

> For instance, varargs is more straightforward to implement with
> right-to-left evaluation of arguments, at least with a stack-based
> calling convention.

You don't see that you're switching topics from "best performance" to
"straightforward to implement"?

The order matters only for arguments that have side effects.  Something like
f(a,b,"foo",x+y) can be evaluated in any order, even if the abstract semantics
calls for strict left to right.

If there are side effects, the order is required so that the same result
is reproduced no matter what. The code generated by the compiler from
a straightforward expression like f(i++, i++) should be no slower
than from an explicit refactoring like 
{ int temp0 = i++, temp1 = i++; f(temp0, temp1); }.

> Order of evaluation may not matter for
> register-based calling conventions, but if an implementation uses both,
> it makes sense to use the same order.

Speaking of stacks and registers, machine languages by and large well-defined
evaluation order, so it's laughable for a "higher level assembly" to screw this
up.

There have been some historic oddballs like early RISC processors that blindly
fetched instructions in sequence even though a branch is happening, requiring
the compiler or assembler to fill the delay slots sensibly or stick in NOPs.

It's the same theme theme like unspecified evaluation order in C: unsafe hack
for ease of implementation.

[toc] | [prev] | [next] | [standalone]


#16987 — Re: what is the right value about a = a++;

FromKenneth Brody <kenbrody@spamcop.net>
Date2012-02-09 12:49 -0500
SubjectRe: what is the right value about a = a++;
Message-ID<zZmdnTwfHsnrmqnSnZ2dnUVZ_hydnZ2d@bestweb.net>
In reply to#16954
On 2/8/2012 7:15 PM, Kaz Kylheku wrote:
> On 2012-02-07, Stephen Sprunk<stephen@sprunk.org>  wrote:
[...]
>> For instance, varargs is more straightforward to implement with
>> right-to-left evaluation of arguments, at least with a stack-based
>> calling convention.
>
> You don't see that you're switching topics from "best performance" to
> "straightforward to implement"?
>
> The order matters only for arguments that have side effects.  Something like
> f(a,b,"foo",x+y) can be evaluated in any order, even if the abstract semantics
> calls for strict left to right.
>
> If there are side effects, the order is required so that the same result
> is reproduced no matter what.

... unless the code invokes UB.

And, what about "unspecified" and/or "implementation-defined"?

There is no guarantee that this will give the same result "no matter what":

     foobar(printf("foo"),printf("bar"));

> The code generated by the compiler from
> a straightforward expression like f(i++, i++) should be no slower
> than from an explicit refactoring like
> { int temp0 = i++, temp1 = i++; f(temp0, temp1); }.

But the Standard makes no guarantees that your sample is the "as-if" that 
must result.  It could just as validly be "as if"

     int temp = i;
     i += 2;
     f(temp,temp);

(In fact, given that the code is UB, "anything" is "legal", though there are 
limited "likely, except for the DS-9000" results.)

[...]

-- 
Kenneth Brody

[toc] | [prev] | [next] | [standalone]


#17012 — Re: what is the right value about a = a++;

FromKaz Kylheku <kaz@kylheku.com>
Date2012-02-09 23:51 +0000
SubjectRe: what is the right value about a = a++;
Message-ID<20120209154542.403@kylheku.com>
In reply to#16987
On 2012-02-09, Kenneth Brody <kenbrody@spamcop.net> wrote:
> There is no guarantee that this will give the same result "no matter what":
>
>      foobar(printf("foo"),printf("bar"));

No guarantee /now/. In this discussion thread, you are required to think
outside of the box, and keep a clean mental separation between the language as
it is, and the fantasy language in which evaluation orders are constrained
that is being discussed.

>> The code generated by the compiler from
>> a straightforward expression like f(i++, i++) should be no slower
>> than from an explicit refactoring like
>> { int temp0 = i++, temp1 = i++; f(temp0, temp1); }.
>
> But the Standard makes no guarantees that your sample is the "as-if" that 
> must result. 

The "compiler" above refers to one which ensures left to right,
bottom-up evaluation order. I.e. the behavior of 
{ int temp0 = i++, temp1 = i++; f(temp0, temp1); } could be obtained
simply by expressing f(i++, i++) with such a compiler.

[toc] | [prev] | [next] | [standalone]


#16942 — Re: what is the right value about a = a++;

FromKenneth Brody <kenbrody@spamcop.net>
Date2012-02-08 15:39 -0500
SubjectRe: what is the right value about a = a++;
Message-ID<27WdnWl1SYYBQK_SnZ2dnUVZ_q2dnZ2d@bestweb.net>
In reply to#16868
On 2/7/2012 4:50 PM, Richard Harter wrote:
> On Tue, 07 Feb 2012 15:12:53 -0500, Kenneth Brody
> <kenbrody@spamcop.net>  wrote:
>
>> On 2/7/2012 3:15 AM, Kaz Kylheku wrote:
>>> On 2012-02-07, Barry Schwarz<schwarzb@dqel.com>   wrote:
>>>> On Mon, 6 Feb 2012 02:33:24 -0800 (PST), lujnan<lujnan@gmail.com>
>>>> wrote:
>>>>
>>>>> On Feb 6, 5:45 pm, bert<bert.hutchi...@btinternet.com>   wrote:
>>>>>> On Monday, February 6, 2012 8:10:00 AM UTC, lujnan wrote:
>>>>>>> b = a = a++;
>> [...]
>>> I don't want diagnostics; I want strict left to right evaluation order
>>> of operands and subexpressions that complete their side effects before
>>> yielding a value.
>>
>> So, what you are really saying, is you want to eliminate most of C's
>> optimization abilities, by restricting the order in which the expression
>> *must* be evaluated, and side effects *must* be completed?
>
> Well, no, he isn't saying any such thing.  You just made it up.  The
> fact that evaluation order in C is left to the compilers has very
> little to do with optimization; it is a historical artifact that came
> from endorsing existing practice when the ANSI standard was put
> together.  Existing practice then was that compiler writers could do
> evaluations in whatever they pleased and they did.

Well, not having access to the Standards committee, I can only speculate. 
However, if evaluation order were the only thing at stake here, things would 
have been left as "unspecified" rather than "undefined".

Consider the fact that, in a "well behaved" program, the order of evaluation 
doesn't matter.  Consider, too, that an optimizer may change the order of 
evaluation to something more "efficient" on a given target platform.

The truth of the matter is, is that when, precisely, a side effect most 
efficiently takes effect, is very platform-dependent, and can even vary from 
expression to expression on a given platform.

> Granted there is no point in whining about C's lack of a well defined
> evaluation.  C is what it is and "undefined" is pretty much carved in
> stone.  But it has very little to do with optimization and a lot to do
> with "that's the way things are; suck it up cupcake and live with it."

In the 30+ years of programming in C, I don't believe I've ever had the need 
to write code which depended on side-effects being completed in "the right 
order" within a single statement.  Whether that's because I know that 
there's no such thing as "the right order", or because I never came across a 
scenario where that might be useful, I cannot say, but I'm leaning towards 
the latter.

-- 
Kenneth Brody

[toc] | [prev] | [next] | [standalone]


Page 3 of 6 — ← Prev page 1 2 [3] 4 5 6  Next page →

Back to top | Article view | comp.lang.c


csiph-web