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 2 of 6 — ← Prev page 1 [2] 3 4 5 6  Next page →


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

FromKenneth Brody <kenbrody@spamcop.net>
Date2012-02-25 16:51 -0500
SubjectRe: what is the right value about a = a++;
Message-ID<erGdnXu9VrdnytTSnZ2dnUVZ_q6dnZ2d@bestweb.net>
In reply to#17944
On 2/25/2012 2:34 PM, Richard Harter wrote:
> On Sat, 25 Feb 2012 11:13:06 -0800, Philip Lantz<prl@canterey.us>
> wrote:
>
>> Ike Naar wrote:
>>> On 2012-02-25, Shao Miller<sha0.miller@gmail.com>  wrote:
>>>> On 2/21/2012 23:28, Kaz Kylheku wrote:
>>>>>     putchar('x') + putchar('x');
>>>>
>>>> Doesn't that output a "bold 'x'" if they are evaluated
>>>> simultaneously?
>
> This is a joke.
>
>>>
>>> Doesn't 6.5.2.2 p 10 forbid simultaneous evaluation?
>
> This also is a joke.
>>
>> Doesn't anybody here understand a joke?
>
> Is this a joke?

Besides, everyone knows that the "right way"[tm] to output a bold 'x' is:

     printf("\033[1m%c\033[0m",'x');

-- 
Kenneth Brody

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


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

Fromlawrence.jones@siemens.com
Date2012-02-27 16:12 -0500
SubjectRe: what is the right value about a = a++;
Message-ID<278t19-ur3.ln1@jones.homeip.net>
In reply to#17916
Ike Naar <ike@iceland.freeshell.org> wrote:
> On 2012-02-25, Shao Miller <sha0.miller@gmail.com> wrote:
> > On 2/21/2012 23:28, Kaz Kylheku wrote:
> >> The following has to produce two x's, even now; though we don't know which
> >> expression's x is printed first:
> >>
> >>    putchar('x') + putchar('x');
> >
> > Doesn't that output a "bold 'x'" if they are evaluated simultaneously?
> 
> Doesn't 6.5.2.2 p 10 forbid simultaneous evaluation?

This started out as a joke, but there's an important point to be made
here.  Note carefully 7.1.4p1:

	Any function declared in a header may be additionally
	implemented as a function-like macro defined in the header....
	Any invocation of a library function that is implemented as a
	macro shall expand to code that evaluates each of its arguments
	exactly once, fully protected by parentheses where necessary, so
	it is generally safe to use arbitrary expressions as
	arguments.186)

	186) Such macros might not contain the sequence points that the
	corresponding function calls do.

So, although you're guaranteed that actual function calls aren't executed
simultaneously, there's no guarantee that library routines are actually
implemented as function calls unless you're careful to avoid any
potential macro version.
-- 
Larry Jones

Honey, are we out of aspirin again? -- Calvin's Dad

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


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

FromIke Naar <ike@iceland.freeshell.org>
Date2012-02-27 22:42 +0000
SubjectRe: what is the right value about a = a++;
Message-ID<slrn3vfsjko1n4.17q.ike@iceland.freeshell.org>
In reply to#17994
On 2012-02-27, lawrence.jones@siemens.com <lawrence.jones@siemens.com> wrote:
> Ike Naar <ike@iceland.freeshell.org> wrote:
>> On 2012-02-25, Shao Miller <sha0.miller@gmail.com> wrote:
>> > On 2/21/2012 23:28, Kaz Kylheku wrote:
>> >> The following has to produce two x's, even now; though we don't know which
>> >> expression's x is printed first:
>> >>
>> >>    putchar('x') + putchar('x');
>> >
>> > Doesn't that output a "bold 'x'" if they are evaluated simultaneously?
>> 
>> Doesn't 6.5.2.2 p 10 forbid simultaneous evaluation?
>
> This started out as a joke, but there's an important point to be made
> here.  Note carefully 7.1.4p1:
>
> 	Any function declared in a header may be additionally
> 	implemented as a function-like macro defined in the header....
> 	Any invocation of a library function that is implemented as a
> 	macro shall expand to code that evaluates each of its arguments
> 	exactly once, fully protected by parentheses where necessary, so
> 	it is generally safe to use arbitrary expressions as
> 	arguments.186)
>
> 	186) Such macros might not contain the sequence points that the
> 	corresponding function calls do.
>
> So, although you're guaranteed that actual function calls aren't executed
> simultaneously, there's no guarantee that library routines are actually
> implemented as function calls unless you're careful to avoid any
> potential macro version.

Would parenthesizing the function name, as in

    (putchar)('x') + (putchar)('x');

be sufficient to make sure the non-macro verion is used?

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


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

FromShao Miller <sha0.miller@gmail.com>
Date2012-02-27 18:54 -0500
SubjectRe: what is the right value about a = a++;
Message-ID<jih52n$bo3$1@dont-email.me>
In reply to#18003
On 2/27/2012 17:42, Ike Naar wrote:
> On 2012-02-27, lawrence.jones@siemens.com<lawrence.jones@siemens.com>  wrote:
>> Ike Naar<ike@iceland.freeshell.org>  wrote:
>>> On 2012-02-25, Shao Miller<sha0.miller@gmail.com>  wrote:
>>>> On 2/21/2012 23:28, Kaz Kylheku wrote:
>>>>> The following has to produce two x's, even now; though we don't know which
>>>>> expression's x is printed first:
>>>>>
>>>>>     putchar('x') + putchar('x');
>>>>
>>>> Doesn't that output a "bold 'x'" if they are evaluated simultaneously?
>>>
>>> Doesn't 6.5.2.2 p 10 forbid simultaneous evaluation?
>>
>> This started out as a joke, but there's an important point to be made
>> here.  Note carefully 7.1.4p1:
>>
>> 	Any function declared in a header may be additionally
>> 	implemented as a function-like macro defined in the header....
>> 	Any invocation of a library function that is implemented as a
>> 	macro shall expand to code that evaluates each of its arguments
>> 	exactly once, fully protected by parentheses where necessary, so
>> 	it is generally safe to use arbitrary expressions as
>> 	arguments.186)
>>
>> 	186) Such macros might not contain the sequence points that the
>> 	corresponding function calls do.
>>
>> So, although you're guaranteed that actual function calls aren't executed
>> simultaneously, there's no guarantee that library routines are actually
>> implemented as function calls unless you're careful to avoid any
>> potential macro version.
>
> Would parenthesizing the function name, as in
>
>      (putchar)('x') + (putchar)('x');
>
> be sufficient to make sure the non-macro verion is used?

That's described in the same paragraph.  Also described is #undef usage.

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


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

FromBarry Schwarz <schwarzb@dqel.com>
Date2012-02-07 09:26 -0800
SubjectRe: what is the right value about a = a++;
Message-ID<08l2j71ccks3topgdrup4gmq3c130dgsts@4ax.com>
In reply to#16827
On Tue, 7 Feb 2012 00:31:05 -0800 (PST), lujnan <lujnan@gmail.com>
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.
>
>i agree with your point of view.

Do you drive your car into lakes?  Do you use a screwdriver as a
soldering iron?  Then why are you using a programming tool that
doesn't do what you want when you already know of one that does?

-- 
Remove del for email

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


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

FromKenneth Brody <kenbrody@spamcop.net>
Date2012-02-07 15:12 -0500
SubjectRe: what is the right value about a = a++;
Message-ID<qdadndbp0NhHGKzSnZ2dnUVZ_uCdnZ2d@bestweb.net>
In reply to#16825
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?

[...]

-- 
Kenneth Brody

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


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

Fromcri@tiac.net (Richard Harter)
Date2012-02-07 21:50 +0000
SubjectRe: what is the right value about a = a++;
Message-ID<4f319955.234650417@text.giganews.com>
In reply to#16862
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.

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]


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

FromStephen Sprunk <stephen@sprunk.org>
Date2012-02-07 16:51 -0600
SubjectRe: what is the right value about a = a++;
Message-ID<jgs9t7$5se$1@dont-email.me>
In reply to#16868
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.

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.

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]


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

FromRobert Wessel <robertwessel2@yahoo.com>
Date2012-02-07 22:49 -0600
SubjectRe: what is the right value about a = a++;
Message-ID<rjv3j7p3ntaitmqapv0hf6o6ov7l87bdnh@4ax.com>
In reply to#16879
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.
>
>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.


Depends on which way your stack grows - with downward growth it's
usually easiest to evaluate varargs right-to-left, but for an upwards
growing stack left-to-right is usually easier.

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


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

FromStephen Sprunk <stephen@sprunk.org>
Date2012-02-08 14:08 -0600
SubjectRe: what is the right value about a = a++;
Message-ID<jguko9$q87$1@dont-email.me>
In reply to#16909
On 07-Feb-12 22:49, Robert Wessel 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.
>>
>> 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.
> 
> Depends on which way your stack grows - with downward growth it's
> usually easiest to evaluate varargs right-to-left, but for an upwards
> growing stack left-to-right is usually easier.

How would stack growth direction matter?  What matters for varargs is
that the first argument is on the top of the stack, regardless of which
way it grows.  If you push the arguments from right to left, the first
argument ends up on top.  You _could_ evaluate the arguments from left
to right, store them in registers or elsewhere in memory, and then push
from right to left, but why go through that extra effort?

(This, of course, assumes a stack-based calling convention for varargs
calls, as all of the ABIs I'm familiar with dictate, and possibly for
other calls.)

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]


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

FromKaz Kylheku <kaz@kylheku.com>
Date2012-02-09 00:18 +0000
SubjectRe: what is the right value about a = a++;
Message-ID<20120208161646.35@kylheku.com>
In reply to#16936
On 2012-02-08, Stephen Sprunk <stephen@sprunk.org> wrote:
> On 07-Feb-12 22:49, Robert Wessel 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.
>>>
>>> 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.
>> 
>> Depends on which way your stack grows - with downward growth it's
>> usually easiest to evaluate varargs right-to-left, but for an upwards
>> growing stack left-to-right is usually easier.
>
> How would stack growth direction matter?  What matters for varargs is
> that the first argument is on the top of the stack, regardless of which
> way it grows.  If you push the arguments from right to left, the first
> argument ends up on top.  You _could_ evaluate the arguments from left
> to right, store them in registers or elsewhere in memory, and then push
> from right to left, but why go through that extra effort?

Or you could wake up and realize that the stack can be indexed like an array,
unless you're working with a target language that really has only push and
pop, with no other access to the stack. (Good luck implementing local
variables efficiently, etc).

You can allocate the space for N arguments, and then store valuews into
that stack space in whatever order is convenient, while obeying
the abstract evaluation order (in those situations where it potentially
makes a difference).

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


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

FromKenneth Brody <kenbrody@spamcop.net>
Date2012-02-09 13:06 -0500
SubjectRe: what is the right value about a = a++;
Message-ID<2MKdnZv4BcDflqnSnZ2dnUVZ_vadnZ2d@bestweb.net>
In reply to#16955
On 2/8/2012 7:18 PM, Kaz Kylheku wrote:
[...]
> Or you could wake up and realize that the stack can be indexed like an array,
> unless you're working with a target language that really has only push and
> pop, with no other access to the stack. (Good luck implementing local
> variables efficiently, etc).
>
> You can allocate the space for N arguments, and then store valuews into
> that stack space in whatever order is convenient, while obeying
> the abstract evaluation order (in those situations where it potentially
> makes a difference).

Once again, conformity versus efficiency.

The efficient:

     PUSH C
     PUSH B
     PUSH A

versus the conforming:

     SUB  SP,12
     STOR [SP],A
     STOR [SP+4],B
     STOR [SP+8],C

(Note, of course, that it is possible that there are machines on which the 
calculated-store is faster than push, and may improve speed even with the 
added stack-adjust, in which case it is certainly free to generate such 
code.  The problem comes when you mandate it.)

-- 
Kenneth Brody

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


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

FromStephen Sprunk <stephen@sprunk.org>
Date2012-02-09 13:58 -0600
SubjectRe: what is the right value about a = a++;
Message-ID<jh18h4$at0$1@dont-email.me>
In reply to#16988
On 09-Feb-12 12:06, Kenneth Brody wrote:
> On 2/8/2012 7:18 PM, Kaz Kylheku wrote:
>> Or you could wake up and realize that the stack can be indexed like
>> an array, unless you're working with a target language that really
>> has only push and pop, with no other access to the stack. (Good luck
>> implementing local variables efficiently, etc).
>>
>> You can allocate the space for N arguments, and then store valuews
>> into that stack space in whatever order is convenient, while obeying
>> the abstract evaluation order (in those situations where it
>> potentially makes a difference).
> 
> Once again, conformity versus efficiency.
> 
> The efficient:
> 
>     PUSH C
>     PUSH B
>     PUSH A
> 
> versus the conforming:
> 
>     SUB  SP,12
>     STOR [SP],A
>     STOR [SP+4],B
>     STOR [SP+8],C
> 
> (Note, of course, that it is possible that there are machines on which
> the calculated-store is faster than push, and may improve speed even
> with the added stack-adjust, in which case it is certainly free to
> generate such code.  The problem comes when you mandate it.)

Note that many modern CPUs can execute the latter version's three stores
in parallel, whereas the three simple pushes have an implicit dependency
on the stack pointer and may have to be executed serially, so the latter
is what compilers usually emit today.

However, that _wasn't_ the case back when all this stuff was being
decided: everything was serial, so the former version was faster as well
as smaller, both of which were a big deal back in the day.

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]


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

FromKaz Kylheku <kaz@kylheku.com>
Date2012-02-09 23:52 +0000
SubjectRe: what is the right value about a = a++;
Message-ID<20120209155125.698@kylheku.com>
In reply to#16988
On 2012-02-09, Kenneth Brody <kenbrody@spamcop.net> wrote:
> On 2/8/2012 7:18 PM, Kaz Kylheku wrote:
> [...]
>> Or you could wake up and realize that the stack can be indexed like an array,
>> unless you're working with a target language that really has only push and
>> pop, with no other access to the stack. (Good luck implementing local
>> variables efficiently, etc).
>>
>> You can allocate the space for N arguments, and then store valuews into
>> that stack space in whatever order is convenient, while obeying
>> the abstract evaluation order (in those situations where it potentially
>> makes a difference).
>
> Once again, conformity versus efficiency.
>
> The efficient:
>
>      PUSH C
>      PUSH B
>      PUSH A

This is conforming, too if C, B and A don't have any side effects.

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


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

Fromjgk@panix.com (Joe keane)
Date2012-02-10 21:45 +0000
SubjectRe: what is the right value about a = a++;
Message-ID<jh4358$p4g$1@reader1.panix.com>
In reply to#16988
In article <2MKdnZv4BcDflqnSnZ2dnUVZ_vadnZ2d@bestweb.net>,
Kenneth Brody  <kenbrody@spamcop.net> wrote:
>The efficient:
>
>     PUSH C
>     PUSH B
>     PUSH A
>
>versus the conforming:
>
>     SUB  SP,12
>     STOR [SP],A
>     STOR [SP+4],B
>     STOR [SP+8],C
>
>(Note, of course, that it is possible that there are machines on which the 
>calculated-store is faster than push, and may improve speed even with the 
>added stack-adjust, in which case it is certainly free to generate such 
>code.  The problem comes when you mandate it.)

I'm almost sure that the Pentium ran consecutive pushes two per cycle.

There is probably some window where this change was faster, but it seems
short-sighted; if the compiler guys had said 'we're going to use your
instructions like you said', i'm pretty sure that the hardware guys
would ensure that it's competitive.

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


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

FromPhil Carmody <thefatphil_demunged@yahoo.co.uk>
Date2012-02-22 00:09 +0200
SubjectRe: what is the right value about a = a++;
Message-ID<87hayjsus4.fsf@bazspaz.fatphil.org>
In reply to#17083
jgk@panix.com (Joe keane) writes:
> In article <2MKdnZv4BcDflqnSnZ2dnUVZ_vadnZ2d@bestweb.net>,
> Kenneth Brody  <kenbrody@spamcop.net> wrote:
> >The efficient:
> >
> >     PUSH C
> >     PUSH B
> >     PUSH A
> >
> >versus the conforming:
> >
> >     SUB  SP,12
> >     STOR [SP],A
> >     STOR [SP+4],B
> >     STOR [SP+8],C
> >
> >(Note, of course, that it is possible that there are machines on which the 
> >calculated-store is faster than push, and may improve speed even with the 
> >added stack-adjust, in which case it is certainly free to generate such 
> >code.  The problem comes when you mandate it.)
> 
> I'm almost sure that the Pentium ran consecutive pushes two per cycle.

You remember correctly. push-after-push was a known often-used case 
that was optimised for. The latter of course has an AGI, which was 
very expensive on a Pentium. So from a 90's persective, the above
looks like H/W-optimised vs. S/W pessimised.

Phil
-- 
> I'd argue that there is much evidence for the existence of a God.
Pics or it didn't happen.
-- Tom (/. uid 822)

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


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

FromRobert Wessel <robertwessel2@yahoo.com>
Date2012-02-08 22:35 -0600
SubjectRe: what is the right value about a = a++;
Message-ID<svi6j71vnemlmo5ppe2htercomdvrkgpma@4ax.com>
In reply to#16936
On Wed, 08 Feb 2012 14:08:40 -0600, Stephen Sprunk
<stephen@sprunk.org> wrote:

>On 07-Feb-12 22:49, Robert Wessel 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.
>>>
>>> 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.
>> 
>> Depends on which way your stack grows - with downward growth it's
>> usually easiest to evaluate varargs right-to-left, but for an upwards
>> growing stack left-to-right is usually easier.
>
>How would stack growth direction matter?  What matters for varargs is
>that the first argument is on the top of the stack, regardless of which
>way it grows.  If you push the arguments from right to left, the first
>argument ends up on top.  You _could_ evaluate the arguments from left
>to right, store them in registers or elsewhere in memory, and then push
>from right to left, but why go through that extra effort?
>
>(This, of course, assumes a stack-based calling convention for varargs
>calls, as all of the ABIs I'm familiar with dictate, and possibly for
>other calls.)


So long as you can conveniently reference successive arguments with
increasing negative offsets, which is usually the case.  The
implementation I was thinking of supports only positive offsets
(obviously you can synthesize negative offsets), and the convention
was to pass a pointer to the first argument.  Of course that's not
really dependent on stack growth direction, you'd have the same issue
(in reverse) with a downwards growing stack on a machine that
perversely supported only negative offsets.

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


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

FromKenneth Brody <kenbrody@spamcop.net>
Date2012-02-08 15:42 -0500
SubjectRe: what is the right value about a = a++;
Message-ID<27WdnWh1SYavQ6_SnZ2dnUVZ_q2dnZ2d@bestweb.net>
In reply to#16909
On 2/7/2012 11:49 PM, Robert Wessel wrote:
> On Tue, 07 Feb 2012 16:51:17 -0600, Stephen Sprunk
> <stephen@sprunk.org>  wrote:
[...]
>> 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.
>>
>> 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.
>
>
> Depends on which way your stack grows - with downward growth it's
> usually easiest to evaluate varargs right-to-left, but for an upwards
> growing stack left-to-right is usually easier.

I'm not sure why the direction in which the stack grows would matter.  The 
"top of the stack" is still the "top" whether it's the highest address or 
lowest currently used.

-- 
Kenneth Brody

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


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

Fromcri@tiac.net (Richard Harter)
Date2012-02-08 14:47 +0000
SubjectRe: what is the right value about a = a++;
Message-ID<4f327fb1.293624067@text.giganews.com>
In reply to#16879
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.

>
>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.    

Historically the variations weren't a matter of performance - for the
most part the performance of the early compilers was less than
stellar.  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.    

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.

  

    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?

It was one thing to say that C is what it is, so suck it up and deal
with it.  It is quite 





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


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

FromStephen Sprunk <stephen@sprunk.org>
Date2012-02-08 14:29 -0600
SubjectRe: what is the right value about a = a++;
Message-ID<jgului$1t5$1@dont-email.me>
In reply to#16925
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".

>> 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.  Remember, we're talking about
long ago when compilers were rather dumb and most popular architectures
were register-starved.  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.

> 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]


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

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


csiph-web