The Unix Heritage Society mailing list
 help / color / mirror / Atom feed
From: scj@yaccman.com (Steve Johnson)
Subject: [TUHS] Unix stories
Date: Wed, 04 Jan 2017 10:51:37 -0800	[thread overview]
Message-ID: <6a969f4310c22211e164a971e27a3af9121176cd@webmail.yaccman.com> (raw)
In-Reply-To: <017201d266ab$cda885a0$68f990e0$@ronnatalie.com>

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 2813 bytes --]

Let me contaminate this philosophical discussion with some history.

Long long ago, computers were slow and didn't have much memory. 
Because C was targeting system code, it was important to make things
run efficiently.  And the PDP-11 had autoincrement and
autodecrement  hardware.
Early machines also had some kinds of memory management, but most
specified a base and limit.  DEC allowed you to protect the end of a
block of memory, which made it possible to grow the stack backwards
and still be able to add more stack space if you ran out.  But many
other machines required that the stack grow upwards.
The problem this caused was when you had
    foo( f(), g() )
In backward-growing stacks, the most efficient thing was to call g
first, then f.
In forward-growing stacks, the most efficient thing was to call f
first, then g.
For whatever reason, Dennis decided that efficiency on a particular
architecture was more important than consistency, so when f() and g()
had side effects, their order was undefined.
Autoincrement and Autodecrement also got tarred by the same brush:
     foo( *p++, *p++ )
had a slew of "correct" implementations, including ones where p was
incremented twice AFTER the call of foo had returned.  The situation
became critical when getc() was implemented as a macro that pulled
bytes out of an I/O buffer and used autoincrement to do so.  After
some discussion, what I implemented in PCC was that all side effects
of an argument must be carried out before the next argument was
evaluated.  This still didn't solve the argument order problem, but
it did cut down the space of astonishing surprises.

These rules provided rich fodder for Lint, when it came along,
although the function side effect issue was beyond its ken.

Steve

----- Original Message -----
From: "Ron Natalie" <ron@ronnatalie.com>
To:"Random832" <random832 at fastmail.com>, "Steffen Nurpmeso"
<steffen at sdaoden.eu>
Cc:<tuhs at minnie.tuhs.org>
Sent:Wed, 4 Jan 2017 11:58:41 -0500
Subject:Re: [TUHS] Unix stories

 There's a trademark between allowing the compiler to reorder things
and having a defined order of operations.
 Steps like that are well-defined in Java for instance. C lets the
compiler do what it sees fit.

 Note that it's not necessarily any better in assembler. There are
RISC architectures where load-followed-by-store and vice versa may not
always be valid if done in quick succession. Requiring the compiler to
insert sequence points typically wastes a lot of cycles. Assembler
programmers tend to think about what they are doing, the C compiler
tries to do some of this on its own and its not clairvoyant.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://minnie.tuhs.org/pipermail/tuhs/attachments/20170104/06487f69/attachment.html>


  parent reply	other threads:[~2017-01-04 18:51 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-01  5:00 Larry McVoy
2017-01-01  6:48 ` Nick Downing
2017-01-02  2:03   ` Steve Johnson
2017-01-02  2:42     ` Nick Downing
2017-01-02  6:01       ` Steve Nickolas
2017-01-02  6:21         ` Warren Toomey
2017-01-02  6:25         ` Nick Downing
2017-01-04  4:07           ` Steve Nickolas
2017-01-02  7:29       ` arnold
2017-01-02 22:52     ` Dave Horsfall
2017-01-02 22:56       ` Larry McVoy
2017-01-02 22:59         ` Ronald Natalie
2017-01-02 22:58       ` Ronald Natalie
2017-01-02 23:23     ` Tim Bradshaw
2017-01-03  0:49       ` Larry McVoy
2017-01-03 11:36         ` Joerg Schilling
2017-01-04 13:04         ` Steffen Nurpmeso
2017-01-04 14:07           ` Random832
2017-01-04 14:54             ` Ron Natalie
2017-01-04 15:59               ` Random832
2017-01-04 16:30                 ` Steffen Nurpmeso
2017-01-04 16:32                   ` Random832
2017-01-04 16:51                     ` Steffen Nurpmeso
2017-01-04 16:54                       ` Random832
2017-01-04 16:58                         ` Ron Natalie
2017-01-04 17:38                           ` Steffen Nurpmeso
2017-01-04 17:47                             ` Steffen Nurpmeso
2017-01-04 18:51                           ` Steve Johnson [this message]
2017-01-04 17:08                         ` Steffen Nurpmeso
2017-01-04 16:22             ` Steffen Nurpmeso
2017-01-04 16:35               ` Random832
2017-01-04 17:03                 ` Steffen Nurpmeso
2017-02-09 13:46                 ` Steffen Nurpmeso
2017-02-09 14:55                   ` Random832
2017-02-09 17:15                     ` Steffen Nurpmeso
2017-01-01 13:11 ` Ron Natalie
2017-01-01 16:50 Noel Chiappa
2017-01-01 21:45 ` Nemo
2017-01-02  2:53   ` Wesley Parish
2017-01-02 14:30 Doug McIlroy
2017-01-02 18:36 ` Dan Cross

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6a969f4310c22211e164a971e27a3af9121176cd@webmail.yaccman.com \
    --to=scj@yaccman.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).