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


Groups > comp.lang.c > #20857

Re: A question for this group...

From gazelle@shell.xmission.com (Kenny McCormack)
Newsgroups comp.lang.c
Subject Re: A question for this group...
Date 2012-05-16 14:08 +0000
Organization The official candy of the new Millennium
Message-ID <jp0cc7$osc$1@news.xmission.com> (permalink)
References <jou4fd$5uh$1@news.xmission.com> <15497347.287.1337165607109.JavaMail.geo-discussion-forums@vbk4>

Show all headers | View raw


In article <15497347.287.1337165607109.JavaMail.geo-discussion-forums@vbk4>,
 <nick_keighley_nospam@hotmail.com> wrote:
...
>For instance *I'd* expect a straitforward implementation to produce "7 6
>6". But I see I was wrong. How do you explain the output observed?
>Visual C++ produces this output.

The underlying point is that I think it *is* interesting to ask and to
answer why the OP gets the output that he gets.  I also get that result
(using gcc on a Linux system) and, TBH, I can't explain it.  Now, I know the
dogmatic position is that it doesn't matter what output you get, it doesn't
matter why you get the output you get, and it is a waste of time to even
think about thinking about why you get the output you get.  Well, the fact
is that this whole newsgroup is a splendid waste of time.  We're all wasting
time posting here - but we do it because it is fun.  Quite seriously, I
can't see how anyone could disagree with that assessment.

Further, to use my light socket analogy, I think everyone knows you
shouldn't stick your finger in it (except, apparently, your friend...), but
I seriously believe that most people - even well educated people - do not
really know *why* - do not really understand how electricity works.
Therefore, I think the "why" question is much more interesting than the
stock "Don't do that!" response.

Now, I took this code and ran it two different versions of AWK - and got
expected results.  GAWK gives:

 % gawk 'BEGIN {a=5;print a++,a++,++a}'
5 6 8

which is easily explainable as left-to-right evaluation.

TAWK gives 7 6 6, which is also easily explainable as right-to-left evaluation.
I would expect C (at least without its doing any optimization) to give the
same, since C usually uses "cdecl", which is right-to-left (of course, yes,
Keith, I understand, none of this is mandated by the C standards).

But the C results defy logic (at least to me), and I'd be interested to find
out why this happens.  Yes, Keith, we understand, it is all a waste of time,
but as noted above, we're here because the time is there to be wasted.

-- 
Windows 95 n. (Win-doze): A 32 bit extension to a 16 bit user interface for
an 8 bit operating system based on a 4 bit architecture from a 2 bit company
that can't stand 1 bit of competition.

Modern day upgrade --> Windows XP Professional x64: Windows is now a 64 bit
tweak of a 32 bit extension to a 16 bit user interface for an 8 bit
operating system based on a 4 bit architecture from a 2 bit company that
can't stand 1 bit of competition.

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

A question for this group... gazelle@shell.xmission.com (Kenny McCormack) - 2012-05-15 17:41 +0000
  Re: A question for this group... "Chine Bleu, Russie Blanche, et Khmer Rouge" <chine.bleu@yahoo.com> - 2012-05-15 10:44 -0700
    Re: A question for this group... James Kuyper <jameskuyper@verizon.net> - 2012-05-15 14:06 -0400
  Re: A question for this group... William Ahern <william@wilbur.25thandClement.com> - 2012-05-15 13:24 -0700
    Re: A question for this group... Quentin Pope <qp19433@hotmail.NOSPAM.com> - 2012-05-15 20:56 +0000
      Re: A question for this group... nick_keighley_nospam@hotmail.com - 2012-05-16 03:41 -0700
  Re: A question for this group... Old Wolf <oldwolf@inspire.net.nz> - 2012-05-16 02:31 -0700
  Re: A question for this group... nick_keighley_nospam@hotmail.com - 2012-05-16 03:53 -0700
    Re: A question for this group... gazelle@shell.xmission.com (Kenny McCormack) - 2012-05-16 14:08 +0000
      Re: A question for this group... Martin Shobe <martin.shobe@yahoo.com> - 2012-05-16 14:49 +0000
        Re: A question for this group... Martin Shobe <martin.shobe@yahoo.com> - 2012-05-16 14:59 +0000
      Re: A question for this group... Kaz Kylheku <kaz@kylheku.com> - 2012-05-16 16:05 +0000
      Re: A question for this group... Old Wolf <oldwolf@inspire.net.nz> - 2012-05-16 14:29 -0700
    Re: A question for this group... Stephen Sprunk <stephen@sprunk.org> - 2012-05-16 18:18 -0500
  Re: A question for this group... Robert Miles <milesrf@Usenet-News.net> - 2012-06-23 23:22 -0500
  Re: A question for this group... Malcolm McLean <malcolm.mclean5@btinternet.com> - 2012-06-25 02:41 -0700
    Re: A question for this group... gazelle@shell.xmission.com (Kenny McCormack) - 2012-06-25 16:29 +0000
      Re: A question for this group... nick_keighley_nospam@hotmail.com - 2012-06-26 08:27 -0700
        Re: A question for this group... gazelle@shell.xmission.com (Kenny McCormack) - 2012-06-27 09:05 +0000
          Re: A question for this group... nick_keighley_nospam@hotmail.com - 2012-06-27 03:57 -0700
        Re: A question for this group... Neil Cerutti <neilc@norwich.edu> - 2012-06-27 13:49 +0000
          Re: A question for this group... "io_x" <a@b.c.invalid> - 2012-06-28 09:19 +0200
            Re: A question for this group... nick_keighley_nospam@hotmail.com - 2012-06-28 01:59 -0700
              Re: A question for this group... Malcolm McLean <malcolm.mclean5@btinternet.com> - 2012-06-28 04:18 -0700
                Re: A question for this group... Heikki Kallasjoki <fis+usenet@zem.fi> - 2012-06-28 12:14 +0000
                Re: A question for this group... James Kuyper <jameskuyper@verizon.net> - 2012-06-28 08:28 -0400
                Re: A question for this group... James Kuyper <jameskuyper@verizon.net> - 2012-06-28 08:33 -0400
                Re: A question for this group... Malcolm McLean <malcolm.mclean5@btinternet.com> - 2012-06-28 13:07 -0700
                Re: A question for this group... David Thompson <dave.thompson2@verizon.net> - 2012-07-19 02:40 -0400
              Re: A question for this group... "io_x" <a@b.c.invalid> - 2012-06-28 18:58 +0200
                Re: A question for this group... Andrew Cooper <amc96@cam.ac.uk> - 2012-06-29 01:11 +0100
                Re: A question for this group... Philip Lantz <prl@canterey.us> - 2012-07-05 00:21 -0700
                Re: A question for this group... nick_keighley_nospam@hotmail.com - 2012-07-06 00:24 -0700
                Re: A question for this group... Tim Rentsch <txr@alumni.caltech.edu> - 2012-07-06 17:43 -0700

csiph-web