Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #88998
| Path | csiph.com!weretis.net!feeder8.news.weretis.net!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | Keith Thompson <Keith.S.Thompson+u@gmail.com> |
| Newsgroups | comp.lang.c++, comp.lang.c |
| Subject | Re: lvalue assignment difference between C and C++ |
| Date | Mon, 06 Feb 2023 14:43:11 -0800 |
| Organization | None to speak of |
| Lines | 42 |
| Message-ID | <87mt5qe7pc.fsf@nosuchdomain.example.com> (permalink) |
| References | <trltmg$21cft$1@dont-email.me> <0mvDL.68810$b7Kc.34465@fx39.iad> <20230206141733.165@kylheku.com> |
| MIME-Version | 1.0 |
| Content-Type | text/plain; charset=utf-8 |
| Content-Transfer-Encoding | 8bit |
| Injection-Info | reader01.eternal-september.org; posting-host="181ea74528ed435ea473c00f282e1c24"; logging-data="3404979"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18HNZ8ofurNZPvcsjIbQqfL" |
| User-Agent | Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) |
| Cancel-Lock | sha1:TWPFvSB2wsyrxgYVv0eiq1J77lA= sha1:V45409WXbGSL9Z8vQthzCQMdAfQ= |
| Xref | csiph.com comp.lang.c++:88998 comp.lang.c:169210 |
Cross-posted to 2 groups.
Show key headers only | View raw
Kaz Kylheku <864-117-4973@kylheku.com> writes:
> On 2023-02-04, Richard Damon <Richard@Damon-Family.org> wrote:
>> The key difference is that in C, the results of the conditional operator
>> is always an r-value, and thus not suitable for an assignment operator.
>
> Interestingly, unlike C++, ISO C doesn't use the term rvalue (only
> lvalue). However: the term was used in the reference manual for the B
> language, predecessor to C.
>
> A footnote (I'm looking at C99, where it is note #53 on P. 46) says
> "What is sometimes called ‘‘rvalue’’ is in this International Standard
> described as the ‘‘value of an expression’’."
>
> Every regular here knows this trivia; just dredging it up a bit here.
Right, and the way C (non-normatively) defines "rvalue" is a bit odd.
An lvalue is a kind of expression, but an rvalue is the result of
evaluating an expression.
Historically, lvalues and rvalues were kinds of values. An expression
could be "evaluated for its lvalue" or "evaluated for its rvalue",
depending on the context in which it appears. In particular, the left
hand side of an assignment is evaluated for its lvalue (the identify of
the object it designates), and the right hand side of an assignment is
evaluated for its rvalue. Some expressions, such as 42, have rvalues
but not lvalues; thus 42 cannot appear on the LHS of an assignment.
This probably goes back to BCPL, or perhaps even CPL.
C mostly dropped rvalues and redefined an "lvalue" as a kind of
expression.
C++ has a small menagerie of kinds of rvalues and lvalues, all of which
(I think) are kinds of expressions.
I think I prefer the historical meanings, but we're stuck with what the
standards say now. (It took the ISO C standard three tries to define
"lvalue" consistently, so I don't propose rocking that particular boat.)
--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for XCOM Labs
void Void(void) { Void(); } /* The recursive call of the void */
Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
lvalue assignment difference between C and C++ Muttley@dastardlyhq.com - 2023-02-04 15:30 +0000
Re: lvalue assignment difference between C and C++ Richard Damon <Richard@Damon-Family.org> - 2023-02-04 11:04 -0500
Re: lvalue assignment difference between C and C++ Muttley@dastardlyhq.com - 2023-02-04 16:59 +0000
Re: lvalue assignment difference between C and C++ Richard Damon <Richard@Damon-Family.org> - 2023-02-04 13:02 -0500
Re: lvalue assignment difference between C and C++ Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2023-02-04 12:45 -0800
Re: lvalue assignment difference between C and C++ David Brown <david.brown@hesbynett.no> - 2023-02-05 11:42 +0100
Re: lvalue assignment difference between C and C++ Muttley@dastardlyhq.com - 2023-02-06 09:26 +0000
Re: lvalue assignment difference between C and C++ Öö Tiib <ootiib@hot.ee> - 2023-02-06 03:27 -0800
Re: lvalue assignment difference between C and C++ Muttley@dastardlyhq.com - 2023-02-06 15:49 +0000
Re: lvalue assignment difference between C and C++ David Brown <david.brown@hesbynett.no> - 2023-02-06 14:13 +0100
Re: lvalue assignment difference between C and C++ Muttley@dastardlyhq.com - 2023-02-06 15:50 +0000
Re: lvalue assignment difference between C and C++ David Brown <david.brown@hesbynett.no> - 2023-02-06 20:08 +0100
Re: lvalue assignment difference between C and C++ Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2023-02-06 12:47 -0800
Re: lvalue assignment difference between C and C++ Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2023-02-06 13:03 -0800
Re: lvalue assignment difference between C and C++ Muttley@dastardlyhq.com - 2023-02-07 09:24 +0000
Re: lvalue assignment difference between C and C++ Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2023-02-07 11:08 -0800
Re: lvalue assignment difference between C and C++ Muttley@dastardlyhq.com - 2023-02-08 09:23 +0000
Re: lvalue assignment difference between C and C++ Blue-Maned_Hawk <bluemanedhawk@gmail.com> - 2023-02-08 22:13 -0500
Re: lvalue assignment difference between C and C++ James Kuyper <jameskuyper@alumni.caltech.edu> - 2023-02-08 22:53 -0500
Re: lvalue assignment difference between C and C++ Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2023-02-08 22:12 -0800
Re: lvalue assignment difference between C and C++ Ben Bacarisse <ben.usenet@bsb.me.uk> - 2023-02-08 02:52 +0000
Re: lvalue assignment difference between C and C++ Paavo Helde <eesnimi@osa.pri.ee> - 2023-02-06 09:11 +0200
Re: lvalue assignment difference between C and C++ Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2023-02-06 01:01 -0800
Re: lvalue assignment difference between C and C++ Richard Damon <Richard@Damon-Family.org> - 2023-02-06 07:42 -0500
Re: lvalue assignment difference between C and C++ Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2023-02-06 12:59 -0800
Re: lvalue assignment difference between C and C++ Bonita Montero <Bonita.Montero@gmail.com> - 2023-02-07 07:44 +0100
Re: lvalue assignment difference between C and C++ Paavo Helde <eesnimi@osa.pri.ee> - 2023-02-07 09:18 +0200
Re: lvalue assignment difference between C and C++ Tim Rentsch <tr.17687@z991.linuxsc.com> - 2023-02-07 07:50 -0800
Re: lvalue assignment difference between C and C++ Kaz Kylheku <864-117-4973@kylheku.com> - 2023-02-06 22:21 +0000
Re: lvalue assignment difference between C and C++ Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2023-02-06 14:43 -0800
Re: lvalue assignment difference between C and C++ Bonita Montero <Bonita.Montero@gmail.com> - 2023-02-04 19:41 +0100
Re: lvalue assignment difference between C and C++ Andrey Tarasevich <andreytarasevich@hotmail.com> - 2023-02-10 16:19 -0800
Re: lvalue assignment difference between C and C++ Armando di Matteo <armando.dimatteo87@gmail.com> - 2023-02-21 09:15 -0800
Re: lvalue assignment difference between C and C++ Andrey Tarasevich <andreytarasevich@hotmail.com> - 2023-02-21 09:46 -0800
Re: lvalue assignment difference between C and C++ Muttley@dastardlyhq.com - 2023-02-22 09:29 +0000
Re: lvalue assignment difference between C and C++ Öö Tiib <ootiib@hot.ee> - 2023-02-22 01:46 -0800
Re: lvalue assignment difference between C and C++ Tim Rentsch <tr.17687@z991.linuxsc.com> - 2023-02-22 06:36 -0800
csiph-web