Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.lisp > #33124
| From | Kaz Kylheku <847-115-0292@kylheku.com> |
|---|---|
| Newsgroups | comp.lang.lisp |
| Subject | Re: TIL: C++17 sequences assignment the wrong way. |
| Date | 2019-07-19 16:45 +0000 |
| Organization | Aioe.org NNTP Server |
| Message-ID | <20190719093907.216@kylheku.com> (permalink) |
| References | <20190718203039.263@kylheku.com> <7nzhlaglhf.fsf@ecube.ecubist.org> |
On 2019-07-19, Barry Fishman <barry@ecubist.org> wrote:
>
> On 2019-07-19 03:36:55 +00, Kaz Kylheku wrote:
>> C++17 adds a sequence point to assignment. E1 = E2 requires E2 to be
>> completely evaluated first, then E1.
>>
>> Wow, what a jaw-droppingly moronic moment in computing history.
>>
>> They had the right motivation to fix a flaw, at least in one small area,
>> and establish an order where there is chaos.
>>
>> Then they drop the ball by making it backwards.
>
> [Although I spent a long time using C++, I stopped using it a while back,
> and my knowledge of the language has atrophied.]
>
> I presume they were concerned about side effects in things like:
>
> int *p = an_array_of_ints;
> for (int i = 0; i < 3; i++) {
> *p++ = *p + 1;
> }
In C++17, this will reliably calculate the prior value of *p + 1,
store it in *p, and increment p.
But under left-to-right, that can be done just fine:
*p = *p++ + 1;
Back to comp.lang.lisp | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
TIL: C++17 sequences assignment the wrong way. Kaz Kylheku <847-115-0292@kylheku.com> - 2019-07-19 03:36 +0000
Re: TIL: C++17 sequences assignment the wrong way. Barry Fishman <barry@ecubist.org> - 2019-07-19 10:14 -0400
Re: TIL: C++17 sequences assignment the wrong way. Kaz Kylheku <847-115-0292@kylheku.com> - 2019-07-19 16:45 +0000
Re: TIL: C++17 sequences assignment the wrong way. Barry Fishman <barry@ecubist.org> - 2019-07-19 15:55 -0400
Re: TIL: C++17 sequences assignment the wrong way. Stefan Monnier <monnier@iro.umontreal.ca> - 2019-07-19 13:30 -0400
Re: TIL: C++17 sequences assignment the wrong way. Kaz Kylheku <847-115-0292@kylheku.com> - 2019-07-19 18:44 +0000
csiph-web