From: random832@fastmail.com (Random832)
Subject: [TUHS] Unix stories
Date: Wed, 04 Jan 2017 09:07:11 -0500 [thread overview]
Message-ID: <1483538831.1573798.837053385.2EB8CAC9@webmail.messagingengine.com> (raw)
In-Reply-To: <20170104130434.NQFzLGpVU%steffen@sdaoden.eu>
On Wed, Jan 4, 2017, at 08:04, Steffen Nurpmeso wrote:
> terrible aliasing and "sequence point" rules, where i think it is
> clear what i mean when i write "i = j + ++i" (i believe this is
> undefined behaviour).
I assume you're imagining it as being equivalent to i = j + i + 1, with
a redundant store operation.
But why couldn't it equally well mean
i = 0; i += j; i+= ++i
i = 0; i += j; i += (i += 1)
If an architecture were to the most efficient way to assign an additive
expression to a variable to zero it out and add each successive operand
to it.
The example seems contrived, because it's honestly hard to make a
reasonable-sounding case for the prefix operators, and my usual go-to
examples require postfix operators and/or pointers. But to be fair, your
example is contrived too; why wouldn't you just do i += j + 1? But for a
better example, I was in a discussion a couple weeks ago with someone
who thought it was clear what they meant by an expression like this:
*a++ = *a
And not only was I easily able to come up with two reasonable-looking
implementations where it means different things, I guessed wrong on
which one they thought it should mean. My examples were stack-based
architectures with a "store to address" instruction taking operands in
each of the two possible orders, making it natural to evaluate either
the RHS or the address-of-LHS first. A more realistic register-based
architecture with pipelining might make it more efficient to evaluate
one or the other first, or parts of each [assuming more complex
expressions than in the example] mixed together, depending on the exact
data dependencies in both expressions.
> Explicit instrumentation via new language constructs would require
> more man power than paying a standard gremium to define semantics
> which effectively allow more compiler optimization and gain more
> performance and thus a sellable catchphrase, but on the long term
> this surely soils the ground on which we stand.
>
> I for one maintain a codebase that has grown over now almost four
> decades and i still cannot say i stand on grounds of pureness,
> beauty and elegance; attributes which, were possible, brighten up
> everydays work and make a day.
>
> --steffen
next prev parent reply other threads:[~2017-01-04 14:07 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 [this message]
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
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=1483538831.1573798.837053385.2EB8CAC9@webmail.messagingengine.com \
--to=random832@fastmail.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).