Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

If you have a procedure with 10 parameters, you probably missed some.


devel / comp.lang.c / Re: lvalue assignment difference between C and C++

SubjectAuthor
* lvalue assignment difference between C and C++Muttley
+* Re: lvalue assignment difference between C and C++Richard Damon
|+* Re: lvalue assignment difference between C and C++Muttley
||+- Re: lvalue assignment difference between C and C++Richard Damon
||+- Re: lvalue assignment difference between C and C++Keith Thompson
||+* Re: lvalue assignment difference between C and C++David Brown
|||`* Re: lvalue assignment difference between C and C++Muttley
||| +* Re: lvalue assignment difference between C and C++David Brown
||| |`* Re: lvalue assignment difference between C and C++Muttley
||| | +- Re: lvalue assignment difference between C and C++David Brown
||| | `- Re: lvalue assignment difference between C and C++Keith Thompson
||| `* Re: lvalue assignment difference between C and C++Keith Thompson
|||  `* Re: lvalue assignment difference between C and C++Muttley
|||   +* Re: lvalue assignment difference between C and C++Keith Thompson
|||   |+- Re: lvalue assignment difference between C and C++Muttley
|||   |`* Re: lvalue assignment difference between C and C++Blue-Maned_Hawk
|||   | +- Re: lvalue assignment difference between C and C++James Kuyper
|||   | `- Re: lvalue assignment difference between C and C++Keith Thompson
|||   `- Re: lvalue assignment difference between C and C++Ben Bacarisse
||`* Re: lvalue assignment difference between C and C++Paavo Helde
|| +* Re: lvalue assignment difference between C and C++Keith Thompson
|| |`* Re: lvalue assignment difference between C and C++Richard Damon
|| | `- Re: lvalue assignment difference between C and C++Keith Thompson
|| +* Re: lvalue assignment difference between C and C++bart c
|| |`- Re: lvalue assignment difference between C and C++Ben Bacarisse
|| `* Re: lvalue assignment difference between C and C++Bonita Montero
||  `- Re: lvalue assignment difference between C and C++Paavo Helde
|`* Re: lvalue assignment difference between C and C++Kaz Kylheku
| `* Re: lvalue assignment difference between C and C++Keith Thompson
|  `* Re: lvalue assignment difference between C and C++Paul N
|   `* Re: lvalue assignment difference between C and C++Ben Bacarisse
|    `* Re: lvalue assignment difference between C and C++Paul N
|     `- Re: lvalue assignment difference between C and C++Ben Bacarisse
+- Re: lvalue assignment difference between C and C++Bonita Montero
`- Re: lvalue assignment difference between C and C++Andrey Tarasevich

Pages:12
Re: lvalue assignment difference between C and C++

<871qn1mohw.fsf@bsb.me.uk>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=24665&group=comp.lang.c#24665

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: ben.use...@bsb.me.uk (Ben Bacarisse)
Newsgroups: comp.lang.c
Subject: Re: lvalue assignment difference between C and C++
Date: Tue, 07 Feb 2023 16:25:31 +0000
Organization: A noiseless patient Spider
Lines: 66
Message-ID: <871qn1mohw.fsf@bsb.me.uk>
References: <trltmg$21cft$1@dont-email.me> <0mvDL.68810$b7Kc.34465@fx39.iad>
<20230206141733.165@kylheku.com>
<87mt5qe7pc.fsf@nosuchdomain.example.com>
<0f9840b3-7421-47ae-a507-0069cbfed700n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Info: reader01.eternal-september.org; posting-host="1b98da929b1e3dd4e9f4529e03614ec6";
logging-data="4012971"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/mCDZza5y/KHMF/2FmDGZvTI3jK/TbmY0="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
Cancel-Lock: sha1:ds60yxFYbApOtiJkIurs4ScO1TM=
sha1:LJ+QO9ppLBeE5jqxCzXDUsZFudU=
X-BSB-Auth: 1.4aff94937f894dd262f3.20230207162531GMT.871qn1mohw.fsf@bsb.me.uk
 by: Ben Bacarisse - Tue, 7 Feb 2023 16:25 UTC

Paul N <gw7rib@aol.com> writes:

> On Monday, February 6, 2023 at 10:43:27 PM UTC, Keith Thompson wrote:
>> Kaz Kylheku <864-11...@kylheku.com> writes:
>> > On 2023-02-04, Richard Damon <Ric...@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.
>
> Yes, that is how it worked in BCPL. In fact, BCPL has keywords LV and
> RV which can be used to evaluate an expression in its other context,

That was very early BCPL. By the time the book was published (and when
I first used it) all references to rvalues and lvalues had gone! I
think the very detailed distinction made early on was probably a
hangover from CPL and was subsequently found to be unnecessarily fussy.

> but the symbols @ and ! can also do this - I guess the symbols were
> added later and people used them instead,

The early manual (with _lv_ and _rv_ operators) is of the old-school
type where the syntax is given using presentation symbols (often
underlined) that will map to some concrete representation in a
particular implementation. I never used BCPL that old, so I don't know
what was used for _rv_ and _lv_ in practice. Other underlined symbols
were usually written in upper case so I'd guess RV and LV. Did you use
(or even see) BCPL of the era? Though off-topic, I'd love to see some!

I'm not 100% sure that the later @ (essentially "address-of") and unary
! (essentially "dereference") are exactly what the 1967 manual writes as
_rv_ and _lv_. There are enough other differences in that early version
(and the example code at the end is sadly missing) for it to be unclear,
at least to me. Do you know if they were, in fact, just concrete
representations of those keywords?

> leading to C's @ and *.

You mean C's & and *. In the later BCPL, ! was also binary with a!b
being, essentially, C's a[b]. Early BCPL (which is the form that
influenced B and C) used the very clumsy a*[b] form because []s were
also used for function calls. That syntax, sin[pi], definitely comes
from CPL.

--
Ben.

Re: lvalue assignment difference between C and C++

<87edr1e1js.fsf@nosuchdomain.example.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=24666&group=comp.lang.c#24666

  copy link   Newsgroups: comp.lang.c++ comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.lang.c++,comp.lang.c
Subject: Re: lvalue assignment difference between C and C++
Date: Tue, 07 Feb 2023 11:08:23 -0800
Organization: None to speak of
Lines: 28
Message-ID: <87edr1e1js.fsf@nosuchdomain.example.com>
References: <trltmg$21cft$1@dont-email.me> <0mvDL.68810$b7Kc.34465@fx39.iad>
<trm2tb$224hr$1@dont-email.me> <tro15s$2f7lc$1@dont-email.me>
<trqh4c$31588$1@dont-email.me>
<87r0v2ecc0.fsf@nosuchdomain.example.com>
<trt5cs$3gvt8$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: reader01.eternal-september.org; posting-host="4db3b9aae9ba641a7bd7c831368aa4f5";
logging-data="4032366"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18SEW19KxBIQ9L0eRwXq0d/"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:zHh2YzzbtgOynVW9nea+arjh3WY=
sha1:23je+l8xMqC73QDolxM4vSMQhCQ=
 by: Keith Thompson - Tue, 7 Feb 2023 19:08 UTC

Muttley@dastardlyhq.com writes:
> On Mon, 06 Feb 2023 13:03:11 -0800
> Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:
[...]
>>C's grammar is not trivial to parse, due to typedefs. A typedef
>>effectively creates a context-specific keyword, which means the parser
>>has to interact with the symbol table. (Historically, this is because
>>typedefs were introduced relatively late in the evolution of C.)
>
> Could it not cheat and simply treat a typedef as a kind of macro?

No, typedefs have scope, and a declaration in an inner scope can hide a
typedef in an outer scope.

#include <stdio.h>
int main(void) {
typedef int Integer;
{
int Integer = 10;
printf("Integer = %d\n", Integer);
}
// int Integer = 20; // would be a syntax error
}

--
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 */

Re: lvalue assignment difference between C and C++

<87v8kclvgu.fsf@bsb.me.uk>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=24667&group=comp.lang.c#24667

  copy link   Newsgroups: comp.lang.c++ comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: ben.use...@bsb.me.uk (Ben Bacarisse)
Newsgroups: comp.lang.c++,comp.lang.c
Subject: Re: lvalue assignment difference between C and C++
Date: Wed, 08 Feb 2023 02:52:33 +0000
Organization: A noiseless patient Spider
Lines: 23
Message-ID: <87v8kclvgu.fsf@bsb.me.uk>
References: <trltmg$21cft$1@dont-email.me> <0mvDL.68810$b7Kc.34465@fx39.iad>
<trm2tb$224hr$1@dont-email.me> <tro15s$2f7lc$1@dont-email.me>
<trqh4c$31588$1@dont-email.me>
<87r0v2ecc0.fsf@nosuchdomain.example.com>
<trt5cs$3gvt8$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: reader01.eternal-september.org; posting-host="e6c2d21a060000da0f1f780f5cd368fe";
logging-data="7891"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+IJ6lnCtAmJtTWdJIn8lfK9rg8lnUQ/s0="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
Cancel-Lock: sha1:1gaZPmMYA/43It1WCdhfbgAUAMM=
sha1:Eo+eSbiifQ+Kv82AY7bHvXUgcJg=
X-BSB-Auth: 1.77d295da10cf926f302d.20230208025233GMT.87v8kclvgu.fsf@bsb.me.uk
 by: Ben Bacarisse - Wed, 8 Feb 2023 02:52 UTC

Muttley@dastardlyhq.com writes:

> On Mon, 06 Feb 2023 13:03:11 -0800
> Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:
<cut>
>>C's grammar is not trivial to parse, due to typedefs. A typedef
>>effectively creates a context-specific keyword, which means the parser
>>has to interact with the symbol table. (Historically, this is because
>>typedefs were introduced relatively late in the evolution of C.)
>
> Could it not cheat and simply treat a typedef as a kind of macro?

Keith has mentioned the scope issue, but there are other problems with a
simple textual substitution. For example, after

typedef int *T;

the declaration const T x; gives x a const-qualified type (i.e. you
can't assign to x). A simple substitution of "T" for "int *" does not
have the same effect at all.

--
Ben.

Re: lvalue assignment difference between C and C++

<trvpmu$48m5$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=24668&group=comp.lang.c#24668

  copy link   Newsgroups: comp.lang.c++ comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: Mutt...@dastardlyhq.com
Newsgroups: comp.lang.c++,comp.lang.c
Subject: Re: lvalue assignment difference between C and C++
Date: Wed, 8 Feb 2023 09:23:42 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 29
Message-ID: <trvpmu$48m5$1@dont-email.me>
References: <trltmg$21cft$1@dont-email.me> <0mvDL.68810$b7Kc.34465@fx39.iad>
<trm2tb$224hr$1@dont-email.me> <tro15s$2f7lc$1@dont-email.me>
<trqh4c$31588$1@dont-email.me>
<87r0v2ecc0.fsf@nosuchdomain.example.com>
<trt5cs$3gvt8$1@dont-email.me>
<87edr1e1js.fsf@nosuchdomain.example.com>
Injection-Date: Wed, 8 Feb 2023 09:23:42 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="adf850dd2e53d5513311e94b23b46a24";
logging-data="139973"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/H6bDMkfD6bcIh+UdUq5dx"
Cancel-Lock: sha1:Fl6akWewNhRg2FCDactpZF77SYs=
 by: Mutt...@dastardlyhq.com - Wed, 8 Feb 2023 09:23 UTC

On Tue, 07 Feb 2023 11:08:23 -0800
Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:
>Muttley@dastardlyhq.com writes:
>> On Mon, 06 Feb 2023 13:03:11 -0800
>> Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:
>[...]
>>>C's grammar is not trivial to parse, due to typedefs. A typedef
>>>effectively creates a context-specific keyword, which means the parser
>>>has to interact with the symbol table. (Historically, this is because
>>>typedefs were introduced relatively late in the evolution of C.)
>>
>> Could it not cheat and simply treat a typedef as a kind of macro?
>
>No, typedefs have scope, and a declaration in an inner scope can hide a
>typedef in an outer scope.
>
>#include <stdio.h>
>int main(void) {
> typedef int Integer;
> {
> int Integer = 10;
> printf("Integer = %d\n", Integer);
> }
> // int Integer = 20; // would be a syntax error
>}

Do you know I never knew you could do that with C. I thought it was C++ only.
Learnt something new today!

Re: lvalue assignment difference between C and C++

<9f807ac3-fe63-4caa-ac7d-a8d1c849620an@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=24669&group=comp.lang.c#24669

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:a0c:cb92:0:b0:56c:1ac0:37d6 with SMTP id p18-20020a0ccb92000000b0056c1ac037d6mr640621qvk.63.1675891186562;
Wed, 08 Feb 2023 13:19:46 -0800 (PST)
X-Received: by 2002:a81:a541:0:b0:4fe:db73:d9c6 with SMTP id
v1-20020a81a541000000b004fedb73d9c6mr780478ywg.308.1675891186354; Wed, 08 Feb
2023 13:19:46 -0800 (PST)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Wed, 8 Feb 2023 13:19:46 -0800 (PST)
In-Reply-To: <871qn1mohw.fsf@bsb.me.uk>
Injection-Info: google-groups.googlegroups.com; posting-host=88.111.34.149; posting-account=0B-afgoAAABP6274zLUJKa8ZpdIdhsYx
NNTP-Posting-Host: 88.111.34.149
References: <trltmg$21cft$1@dont-email.me> <0mvDL.68810$b7Kc.34465@fx39.iad>
<20230206141733.165@kylheku.com> <87mt5qe7pc.fsf@nosuchdomain.example.com>
<0f9840b3-7421-47ae-a507-0069cbfed700n@googlegroups.com> <871qn1mohw.fsf@bsb.me.uk>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <9f807ac3-fe63-4caa-ac7d-a8d1c849620an@googlegroups.com>
Subject: Re: lvalue assignment difference between C and C++
From: gw7...@aol.com (Paul N)
Injection-Date: Wed, 08 Feb 2023 21:19:46 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 5537
 by: Paul N - Wed, 8 Feb 2023 21:19 UTC

On Tuesday, February 7, 2023 at 4:25:44 PM UTC, Ben Bacarisse wrote:
> Paul N <gw7...@aol.com> writes:
>
> > On Monday, February 6, 2023 at 10:43:27 PM UTC, Keith Thompson wrote:
> >> 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.
> >
> > Yes, that is how it worked in BCPL. In fact, BCPL has keywords LV and
> > RV which can be used to evaluate an expression in its other context,
> That was very early BCPL. By the time the book was published (and when
> I first used it) all references to rvalues and lvalues had gone! I
> think the very detailed distinction made early on was probably a
> hangover from CPL and was subsequently found to be unnecessarily fussy.

I got my information from two books. One, entitled "Programming electronic switching systems" and dated 1976, briefly discusses various programming languages and mentions the two types of evaluation as a key feature of the language, together with keywords RV and LV. It describes an array access as either RV (E1 + E2) or as E1 ↓ E2 (a downward arrow). It's possible the authors had not kept up with recent developments in the language, which is but one of over a dozen described.

The other book is "BCPL: The language and its compiler", dated 1980, printed 1986. As you say, there appears to be no mention of lvalues or rvalues, and no discussion of LV and RV, but the latter are shown in the sample code for the language's syntax analyser. LV seems identical to @ but RV and ! are different as the latter can also be used for arrays, which are now E1 ! E2 as you say below.

> > but the symbols @ and ! can also do this - I guess the symbols were
> > added later and people used them instead,
> The early manual (with _lv_ and _rv_ operators) is of the old-school
> type where the syntax is given using presentation symbols (often
> underlined) that will map to some concrete representation in a
> particular implementation. I never used BCPL that old, so I don't know
> what was used for _rv_ and _lv_ in practice. Other underlined symbols
> were usually written in upper case so I'd guess RV and LV. Did you use
> (or even see) BCPL of the era? Though off-topic, I'd love to see some!

I don't think there are any underlines of any sort in the book. Full stops seem to be the preferred character for concatenating words into a single identifier.

> I'm not 100% sure that the later @ (essentially "address-of") and unary
> ! (essentially "dereference") are exactly what the 1967 manual writes as
> _rv_ and _lv_. There are enough other differences in that early version
> (and the example code at the end is sadly missing) for it to be unclear,
> at least to me. Do you know if they were, in fact, just concrete
> representations of those keywords?

As I said, the older book certainly seems to say that the keywords were simply RV and LV, in capitals.

> > leading to C's @ and *.
> You mean C's & and *.

Mea culpa!

> In the later BCPL, ! was also binary with a!b
> being, essentially, C's a[b]. Early BCPL (which is the form that
> influenced B and C) used the very clumsy a*[b] form because []s were
> also used for function calls. That syntax, sin[pi], definitely comes
> from CPL.

Yes, both round and square brackets are function calls.

Glad to find someone who is interested!

Re: lvalue assignment difference between C and C++

<87wn4rk9ff.fsf@bsb.me.uk>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=24670&group=comp.lang.c#24670

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: ben.use...@bsb.me.uk (Ben Bacarisse)
Newsgroups: comp.lang.c
Subject: Re: lvalue assignment difference between C and C++
Date: Wed, 08 Feb 2023 23:46:12 +0000
Organization: A noiseless patient Spider
Lines: 131
Message-ID: <87wn4rk9ff.fsf@bsb.me.uk>
References: <trltmg$21cft$1@dont-email.me> <0mvDL.68810$b7Kc.34465@fx39.iad>
<20230206141733.165@kylheku.com>
<87mt5qe7pc.fsf@nosuchdomain.example.com>
<0f9840b3-7421-47ae-a507-0069cbfed700n@googlegroups.com>
<871qn1mohw.fsf@bsb.me.uk>
<9f807ac3-fe63-4caa-ac7d-a8d1c849620an@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Info: reader01.eternal-september.org; posting-host="d95101c49a0af21f3154233ad0722f02";
logging-data="419782"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/y6VHfjYQsDIBKM3+fNU+KTlVDdkIhMZ8="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
Cancel-Lock: sha1:Br2m48ho3q3SZzHXguWDwkDXRb8=
sha1:VnSmv4IyuLYzHghWX40KqvcIb68=
X-BSB-Auth: 1.1637d90fd126d2448e96.20230208234612GMT.87wn4rk9ff.fsf@bsb.me.uk
 by: Ben Bacarisse - Wed, 8 Feb 2023 23:46 UTC

Paul N <gw7rib@aol.com> writes:

> On Tuesday, February 7, 2023 at 4:25:44 PM UTC, Ben Bacarisse wrote:
>> Paul N <gw7...@aol.com> writes:
>>
>> > On Monday, February 6, 2023 at 10:43:27 PM UTC, Keith Thompson wrote:
>> >> 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.
>> >
>> > Yes, that is how it worked in BCPL. In fact, BCPL has keywords LV and
>> > RV which can be used to evaluate an expression in its other context,
>> That was very early BCPL. By the time the book was published (and when
>> I first used it) all references to rvalues and lvalues had gone! I
>> think the very detailed distinction made early on was probably a
>> hangover from CPL and was subsequently found to be unnecessarily fussy.
>
> I got my information from two books. One, entitled "Programming
> electronic switching systems" and dated 1976, briefly discusses
> various programming languages and mentions the two types of evaluation
> as a key feature of the language, together with keywords RV and LV. It
> describes an array access as either RV (E1 + E2) or as E1 ↓ E2 (a
> downward arrow). It's possible the authors had not kept up with recent
> developments in the language, which is but one of over a dozen
> described.
>
> The other book is "BCPL: The language and its compiler", dated 1980,
> printed 1986. As you say, there appears to be no mention of lvalues or
> rvalues, and no discussion of LV and RV, but the latter are shown in
> the sample code for the language's syntax analyser. LV seems identical
> to @ but RV and ! are different as the latter can also be used for
> arrays, which are now E1 ! E2 as you say below.

I've got that one (well, had that one would be more accurate) and it
describes what I would call "modern BCPL", if anything from last century
can be modern!

Binary ! is a separate thing. I was wondering if rv and lv are exactly
unary ! and @ in modern BCPL. I need to find more examples of rv and lv
being used in code to be sure.

>> > but the symbols @ and ! can also do this - I guess the symbols were
>> > added later and people used them instead,
>>
>> The early manual (with _lv_ and _rv_ operators) is of the old-school
>> type where the syntax is given using presentation symbols (often
>> underlined) that will map to some concrete representation in a
>> particular implementation. I never used BCPL that old, so I don't know
>> what was used for _rv_ and _lv_ in practice. Other underlined symbols
>> were usually written in upper case so I'd guess RV and LV. Did you use
>> (or even see) BCPL of the era? Though off-topic, I'd love to see some!
>
> I don't think there are any underlines of any sort in the book.

I used Usenet _underline_ notation for putting an line under a word.
Some clients will _underline_ and make *bold* and /italic/ text using _,
* and / characters. I think that ended up confusing the matter.

And I was referring only the very old reference manuals. They were
typically typed with a mechanical typewriter and used underlining to
denote abstract symbols like rv, if, let etc.. In such a notation, a
keyword like let would be underlined and the reader would not
automatically assume that a variable could not be named let. An
implementation would specify how these symbols should really be written
in actual program texts. In the BCPL I used, keywords were written in
UPPER CASE, so you could have

LET let = 42; // not a good idea

Algol 68 used a similar system with bold keywords that could be
represented in several ways. Upper case was one, but sometimes you
could use quotes or single dots: WHILE, 'while', .while were all seen
where the report used bold while. (This was called stropping, but I
don't know why. A metaphorical 'sharpening'?)

I think this convention had died out by the 1980s.

> Full stops seem to be the preferred character for concatenating words
> into a single identifier.

Yes, I think that's always been the case. I was not talking about
that. My post was confusing.

>> I'm not 100% sure that the later @ (essentially "address-of") and unary
>> ! (essentially "dereference") are exactly what the 1967 manual writes as
>> _rv_ and _lv_. There are enough other differences in that early version
>> (and the example code at the end is sadly missing) for it to be unclear,
>> at least to me. Do you know if they were, in fact, just concrete
>> representations of those keywords?
>
> As I said, the older book certainly seems to say that the keywords
> were simply RV and LV, in capitals.
>
>> > leading to C's @ and *.
>> You mean C's & and *.
>
> Mea culpa!
>
>> In the later BCPL, ! was also binary with a!b
>> being, essentially, C's a[b]. Early BCPL (which is the form that
>> influenced B and C) used the very clumsy a*[b] form because []s were
>> also used for function calls. That syntax, sin[pi], definitely comes
>> from CPL.
>
> Yes, both round and square brackets are function calls.
>
> Glad to find someone who is interested!

Thanks for posting. I'd forgotten all about the original RV and LV
symbols.

I was very fond of programming in BCPL and I think a fast, clean
typeless language would still find place these days. It's and odd
fondness since I also like very strict typing as in, say, Haskell. Have
you had a look at Richard's MCPL? Very interesting...

And, as an aside, somewhere along the line BCPL acquired a%b the byte
offset version of a!b. You might remember that string operations were
rather painful without it.

--
Ben.

Re: lvalue assignment difference between C and C++

<ts1ocr$hffi$1@bluemanedhawk.eternal-september.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=24672&group=comp.lang.c#24672

  copy link   Newsgroups: comp.lang.c++ comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!bluemanedhawk.eternal-september.org!.POSTED!not-for-mail
From: bluemane...@gmail.com (Blue-Maned_Hawk)
Newsgroups: comp.lang.c++,comp.lang.c
Subject: Re: lvalue assignment difference between C and C++
Date: Wed, 8 Feb 2023 22:13:31 -0500
Organization: A noiseless patient Spider
Lines: 19
Message-ID: <ts1ocr$hffi$1@bluemanedhawk.eternal-september.org>
References: <trltmg$21cft$1@dont-email.me> <0mvDL.68810$b7Kc.34465@fx39.iad>
<trm2tb$224hr$1@dont-email.me> <tro15s$2f7lc$1@dont-email.me>
<trqh4c$31588$1@dont-email.me> <87r0v2ecc0.fsf@nosuchdomain.example.com>
<trt5cs$3gvt8$1@dont-email.me> <87edr1e1js.fsf@nosuchdomain.example.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: base64
Injection-Date: Thu, 9 Feb 2023 03:13:32 -0000 (UTC)
Injection-Info: bluemanedhawk.eternal-september.org; posting-host="f1aa8a10deb4f6baee0bd64a64f8b673";
logging-data="572914"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+F4UFRpOwgvnFrUeWXanbEj22LS3fI0BY="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.6.1
Cancel-Lock: sha1:VeAE4axEIAEz5eQHrvzmvkyJMV0=
Content-Language: en-US
In-Reply-To: <87edr1e1js.fsf@nosuchdomain.example.com>
 by: Blue-Maned_Hawk - Thu, 9 Feb 2023 03:13 UTC

On 2/7/23 14:08, Keith Thompson wrote:
> Muttley@dastardlyhq.com writes:
>> On Mon, 06 Feb 2023 13:03:11 -0800
>> Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:
> [...]
>>> C's grammar is not trivial to parse, due to typedefs. A typedef
>>> effectively creates a context-specific keyword, which means the parser
>>> has to interact with the symbol table. (Historically, this is because
>>> typedefs were introduced relatively late in the evolution of C.)
>>
>> Could it not cheat and simply treat a typedef as a kind of macro?
>
> No, typedefs have scope, and a declaration in an inner scope can hide a
> typedef in an outer scope.
>
​So could it treat it as a macro that gets `#undef`ed at the end of a scope?
--
⚗︎ | /blu.mɛin.dʰak/ | shortens to "Hawk" | he/him/his/himself/Mr.
bluemanedhawk.github.io
Bitches stole my whole ass ␔🭖᷿᪳𝼗᷍⏧𒒫𐻾ࣛ↉�⃣ quoted-printable, can't
have shit in Thunderbird 😩

Re: lvalue assignment difference between C and C++

<ts1qo8$hoct$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=24673&group=comp.lang.c#24673

  copy link   Newsgroups: comp.lang.c comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: jameskuy...@alumni.caltech.edu (James Kuyper)
Newsgroups: comp.lang.c,comp.lang.c++
Subject: Re: lvalue assignment difference between C and C++
Date: Wed, 8 Feb 2023 22:53:43 -0500
Organization: A noiseless patient Spider
Lines: 43
Message-ID: <ts1qo8$hoct$1@dont-email.me>
References: <trltmg$21cft$1@dont-email.me> <0mvDL.68810$b7Kc.34465@fx39.iad>
<trm2tb$224hr$1@dont-email.me> <tro15s$2f7lc$1@dont-email.me>
<trqh4c$31588$1@dont-email.me> <87r0v2ecc0.fsf@nosuchdomain.example.com>
<trt5cs$3gvt8$1@dont-email.me> <87edr1e1js.fsf@nosuchdomain.example.com>
<ts1ocr$hffi$1@bluemanedhawk.eternal-september.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 9 Feb 2023 03:53:44 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="2b7b3a3157ffb38be2e070ab08194522";
logging-data="582045"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX182GybQlWbvOhK6dveUDwaRHS3AAVO3SIo="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.7.1
Cancel-Lock: sha1:9wmzqvrNB2cMVJq/0hliR0Ak5B4=
Content-Language: en-US
In-Reply-To: <ts1ocr$hffi$1@bluemanedhawk.eternal-september.org>
 by: James Kuyper - Thu, 9 Feb 2023 03:53 UTC

On 2/8/23 22:13, Blue-Maned_Hawk wrote:
> On 2/7/23 14:08, Keith Thompson wrote:
>> Muttley@dastardlyhq.com writes:
>>> On Mon, 06 Feb 2023 13:03:11 -0800
>>> Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:
>> [...]
>>>> C's grammar is not trivial to parse, due to typedefs. A typedef
>>>> effectively creates a context-specific keyword, which means the parser
>>>> has to interact with the symbol table. (Historically, this is because
>>>> typedefs were introduced relatively late in the evolution of C.)
>>>
>>> Could it not cheat and simply treat a typedef as a kind of macro?
>>
>> No, typedefs have scope, and a declaration in an inner scope can hide a
>> typedef in an outer scope.
>>
>
> ​So could it treat it as a macro that gets `#undef`ed at the end of a
> scope?

The same identifier can be two different typedefs in two different
nested scopes. The typedef in the inner scope hides the typedef in the
outer scope, but the typedef in the outer scope becomes visible again at
the end of the inner scope. Therefore, you'd have to have an #undef at
the end of the inner scope immediately followed by a #define.

Note: macro replacement occurs during translation phase 4. Scopes don't
even exist until translation phase 7, and can be affected by some of the
transformations that can occur during translation phase 4. That is to
say, conditional compilation, #include directives or the expansion of a
macro could create or eliminate scopes that would not have been
identified as such in the code as it existed prior to translation phase 4.

Basically, to do something similar to what you're suggesting, you need
to first perform all phase 4, 5, and 6 transformations properly, then
start translation phase 7 parsing to identify where scopes start and
end. Then you have to insert #define and #undef directives in the
appropriate places to implement typedefs, and carry out a
mini-translation phase 4 limited to recognizing those #define and #undef
directives. I don't think that this late phase 4 processing would have
any significant advantage over just biting the bullet and implementing
typedefs correctly during translation phase 7.

Re: lvalue assignment difference between C and C++

<87wn4rcqp5.fsf@nosuchdomain.example.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=24674&group=comp.lang.c#24674

  copy link   Newsgroups: comp.lang.c++ comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.lang.c++,comp.lang.c
Subject: Re: lvalue assignment difference between C and C++
Date: Wed, 08 Feb 2023 22:12:38 -0800
Organization: None to speak of
Lines: 35
Message-ID: <87wn4rcqp5.fsf@nosuchdomain.example.com>
References: <trltmg$21cft$1@dont-email.me> <0mvDL.68810$b7Kc.34465@fx39.iad>
<trm2tb$224hr$1@dont-email.me> <tro15s$2f7lc$1@dont-email.me>
<trqh4c$31588$1@dont-email.me>
<87r0v2ecc0.fsf@nosuchdomain.example.com>
<trt5cs$3gvt8$1@dont-email.me>
<87edr1e1js.fsf@nosuchdomain.example.com>
<ts1ocr$hffi$1@bluemanedhawk.eternal-september.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Info: reader01.eternal-september.org; posting-host="8191dc9d3cc9a723636202e99e75b43d";
logging-data="629235"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18LMYc2gpgf6oe1t8xgSL0B"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:H0iKgvQKGLLo90OC7szfmHhvBQQ=
sha1:cdy1kYyUQ7ffAC9UXAtS8ogpn2k=
 by: Keith Thompson - Thu, 9 Feb 2023 06:12 UTC

Blue-Maned_Hawk <bluemanedhawk@gmail.com> writes:
> On 2/7/23 14:08, Keith Thompson wrote:
>> Muttley@dastardlyhq.com writes:
>>> On Mon, 06 Feb 2023 13:03:11 -0800
>>> Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:
>> [...]
>>>> C's grammar is not trivial to parse, due to typedefs. A typedef
>>>> effectively creates a context-specific keyword, which means the parser
>>>> has to interact with the symbol table. (Historically, this is because
>>>> typedefs were introduced relatively late in the evolution of C.)
>>>
>>> Could it not cheat and simply treat a typedef as a kind of macro?
>> No, typedefs have scope, and a declaration in an inner scope can
>> hide a
>> typedef in an outer scope.
>
> ​So could it treat it as a macro that gets `#undef`ed at the end of a scope?

No, that wouldn't even work for the example I posted. The "macro"
wouldn't be undefined until the end of main.

#include <stdio.h>
int main(void) {
typedef int Integer;
{
int Integer = 10;
printf("Integer = %d\n", Integer);
}
// int Integer = 20; // would be a syntax error
}

--
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 */

Re: lvalue assignment difference between C and C++

<ts6mv1$16gqf$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=24678&group=comp.lang.c#24678

  copy link   Newsgroups: comp.lang.c++ comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: andreyta...@hotmail.com (Andrey Tarasevich)
Newsgroups: comp.lang.c++,comp.lang.c
Subject: Re: lvalue assignment difference between C and C++
Date: Fri, 10 Feb 2023 16:19:44 -0800
Organization: A noiseless patient Spider
Lines: 54
Message-ID: <ts6mv1$16gqf$1@dont-email.me>
References: <trltmg$21cft$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 11 Feb 2023 00:19:45 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="45dc63f99ccf6f1c265189b682b6b3ed";
logging-data="1262415"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/Vc2MS2i3jdaeZEdvcU0XT"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.7.2
Cancel-Lock: sha1:GrB3erJi9qkGoLWThv92eKZVog0=
In-Reply-To: <trltmg$21cft$1@dont-email.me>
Content-Language: en-US
 by: Andrey Tarasevich - Sat, 11 Feb 2023 00:19 UTC

On 02/04/23 7:30 AM, Muttley@dastardlyhq.com wrote:
> Can anyone explain the "official" explanation from whichever standard as to
> why the first assignment only compiles in C++ but not C:

Because C is not C++, and C++ is not C.

This is one of the fundamental core differences between the languages,
which is present in all potentially applicable contexts. You just
stumbled upon one of them - the `?`: operator. There are others:

* Assignment (and compound assignment) in C++ preserves lvalue-ness of
the result

int a, b = 1;
(a = b) = 2;
// Invalid in C, valid in C++
// (and starting from C++11 the behavior is well-defined)

* Prefix increment and decrement in C++ preserves lvalue-ness of the result

int i = 0;
++(++i);
// Invalid in C, valid in C++
// (and starting from C++11 the behavior is well-defined)

C language from the very beginning never cared about preserving the
lvalue-ness of expression results. In C dereference operator (unary `*`)
and its direct derivatives (e.g. `[]` and `->`) are the only operators
that produce lvalue results. Everything else produces rvalues.

C++ completely abandoned and reworked that approach. C++ does the
opposite: it goes to great lengths in order to preserve lvalue-ness of
the result whenever possible. You can see it especially well with `?:`
operator where lvalue-preservation is obviously tricky, since the types
(and value categories) of the second and third operands might not match.
The behavior of `?:` in C++ is defined by a long set of rather
convoluted rules, which depend on how well the types and categories of
the second and third operands match. This illustrates how much effort
C++ is willing to spend on preserving something that C just discarded
nonchalantly.

On can possibly argue that the rationale behind this is introduction of
reference types in C++ (and I'd say that references is just small part
of the story), but the bottom line here is that C and C++ are languages
that adhere to diametrically opposite philosophies wrt that core issue.
These are two completely different languages. The matter can only seem
surprising to those who believe in silly myths, like "C is subset of
C++" and such.

--
Best regards,
Andrey

Pages:12
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor