Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #119801
| Path | csiph.com!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | Keith Thompson <Keith.S.Thompson+u@gmail.com> |
| Newsgroups | comp.lang.c++ |
| Subject | Re: is "x *= ++f * ++f" a valid statement ? |
| Date | Sun, 11 Aug 2024 14:09:41 -0700 |
| Organization | None to speak of |
| Lines | 104 |
| Message-ID | <871q2ug416.fsf@nosuchdomain.example.com> (permalink) |
| References | <v2nivh$1pl7o$1@raubtier-asyl.eternal-september.org> <96127c8d8d204b7c3230828101bc2b6e@www.novabbs.org> <v7n2mj$t6tp$1@dont-email.me> <877cdchj2i.fsf@nosuchdomain.example.com> <86ttgg41yb.fsf@linuxsc.com> <8734nzhjkg.fsf@nosuchdomain.example.com> <87y15rg3wo.fsf@nosuchdomain.example.com> <8634nbp52l.fsf@linuxsc.com> |
| MIME-Version | 1.0 |
| Content-Type | text/plain |
| Injection-Date | Sun, 11 Aug 2024 23:09:42 +0200 (CEST) |
| Injection-Info | dont-email.me; posting-host="4e0a7955da0737aad349c16a734eea4d"; logging-data="3019149"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19b4a0PDdktFvZpGO3Opd4M" |
| User-Agent | Gnus/5.13 (Gnus v5.13) |
| Cancel-Lock | sha1:Hm4rj1isBht7ajKSIKE1o0YCBmQ= sha1:7oz6nP3dn+JP0qTFkjYOhie4MzU= |
| Xref | csiph.com comp.lang.c++:119801 |
Show key headers only | View raw
Tim Rentsch <tr.17687@z991.linuxsc.com> writes:
> Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
>> Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
>>> Tim Rentsch <tr.17687@z991.linuxsc.com> writes:
>>>> Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
>>>>> James Kuyper <jameskuyper@alumni.caltech.edu> writes:
>>>> [...]
>>>>
>>>>>> A minor detail is that a variable must be declared, whereas memory
>>>>>> locations can, for instance, be part of allocated memory for which
>>>>>> no declaration exists - it is still undefined behavior to write
>>>>>> code that applies unsequence side-effects to such memory locations.
>>>>>
>>>>> Digression: I'm not even sure what "variable" means in C++. The
>>>>> standard defines the term, but not in a way that really tells us
>>>>> what it means.
>>>>>
>>>>> "A *variable* is introduced by the declaration of a reference other
>>>>> than a non-static data member or of an object. The variable's name,
>>>>> if any, denotes the reference or object."
>>>>
>>>> What part do you find confusing or hard to understand?
>>>
>>> The missing part that should tell us what a variable *is*.
>>>
>>> It says that certain declarations "introduce" a variable. That's a
>>> statement about variables, but it doesn't say what a variable is.
>>>
>>> Given:
>>>
>>> int n;
>>>
>>> we know that the declaration introduces a variable. Is the object
>>> itself a "variable"? That's the obvious meaning, and it's consistent
>>> with what the standard says. Or is a "variable" some kind of logical
>>> binding between an object and a name? That's also consistent with what
>>> the standard says. Under the latter interpretation, the "variable" has
>>> a name, and that name denotes an object, but the variable is not the
>>> object.
>>>
>>> Given the above declaration, is the introduced variable an object? If
>>> so, or if not, how does your answer follow from what the standard says?
>
> [...]
>
>> But the following paragraph says:
>>
>> A *local entity* is a variable with automatic storage duration
>> (6.7.5.4), a structured binding (9.6) whose corresponding variable
>> is such an entity, or the *this object (7.5.3).
>>
>> Storage duration is an attribute of objects. If a variable can have
>> automatic storage duration, then apparently a variable is an object.
>
> It seems clear that the quoted sentence is meant to be read as
>
> A *local entity* is a variable [associated with an object that
> has] automatic storage duration, [etc].
It seems clear to you. It's not clear to me. If the only way to
understand a passage is to assume it includes extra words, it is at best
poorly written -- and I can't be sure that any assumptions about what it
*really* means are correct.
> I'm not sure if C++ references also have storage durations, in which
> case the word "object" in that sentence might need to be replaced with
> "object or reference". The key point though is that the property of
> having automatic storage duration is meant to be associated with the
> affiliated object or reference rather than with the variable itself.
Perhaps so, but that still doesn't tell me what a "variable" is.
Apparently a "variable" is something *associated with* an object. But
what is it, and how is the concept useful when we already have the
concept of an "object"?
I tried following your advice and searchin for uses of "variable" in the
C++ standard (which, as James Kuyper pointed out, should not be
necessary to understand the definition). It was not helpful. For
example, "Variables with static storage duration are initialized as a
consequence of program initiation.". So a variable is a thing that can
have a storage duration and be initialized? And it's not an object?
I get the impression (quite possibly mistaken) that the authors of the
standard implicitly assume in some places that a variable is an object,
and in other places that it's something else.
The most obvious meaning is that a "variable" is an object that has a
name introduced by a declaration. (I'll gloss over the question of
whether something that's const-qualified is a "variable", but I'm
willing to accept that "variable" doesn't have to mean that something
can vary.) But that's not what the standard says.
I'll note that the C standard does not define or use the term "variable"
(though it does use the word in its non-tecnical sense). Instead it
refers to "objects". Perhaps C++ could have done the same.
If I were to ask you "What is a variable in C++?", could you give a
clear answer? What would that answer be? Is a variable an object or
is it not?
--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
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
is "x *= ++f * ++f" a valid statement ? Bonita Montero <Bonita.Montero@gmail.com> - 2024-05-23 16:14 +0200
Re: is "x *= ++f * ++f" a valid statement ? Andrey Tarasevich <andreytarasevich@hotmail.com> - 2024-06-18 18:53 -0700
Re: is "x *= ++f * ++f" a valid statement ? Bonita Montero <Bonita.Montero@gmail.com> - 2024-06-19 17:40 +0200
Re: is "x *= ++f * ++f" a valid statement ? PLO olcott <polcott333@gmail.com> - 2024-06-21 16:55 -0500
Re: is "x *= ++f * ++f" a valid statement ? PLO Richard Damon <richard@damon-family.org> - 2024-06-21 18:10 -0400
Re: is "x *= ++f * ++f" a valid statement ? PLO olcott <polcott333@gmail.com> - 2024-06-21 18:06 -0500
Re: is "x *= ++f * ++f" a valid statement ? PLO Richard Damon <richard@damon-family.org> - 2024-06-21 20:14 -0400
Re: is "x *= ++f * ++f" a valid statement ? PLO Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2024-06-21 17:35 -0700
Re: is "x *= ++f * ++f" a valid statement ? PLO olcott <polcott333@gmail.com> - 2024-06-21 22:58 -0500
Re: is "x *= ++f * ++f" a valid statement ? PLO Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2024-06-21 23:18 -0700
Re: is "x *= ++f * ++f" a valid statement ? PLO olcott <polcott333@gmail.com> - 2024-06-22 07:38 -0500
Re: is "x *= ++f * ++f" a valid statement ? PLO Richard Damon <richard@damon-family.org> - 2024-06-22 09:45 -0400
Re: is "x *= ++f * ++f" a valid statement ? PLO olcott <polcott333@gmail.com> - 2024-06-22 09:13 -0500
Re: is "x *= ++f * ++f" a valid statement ? PLO Richard Damon <richard@damon-family.org> - 2024-06-22 10:23 -0400
Re: is "x *= ++f * ++f" a valid statement ? PLO Mikko <mikko.levanto@iki.fi> - 2024-06-23 11:48 +0300
Re: is "x *= ++f * ++f" a valid statement ? PLO Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2024-06-22 17:54 -0700
Re: is "x *= ++f * ++f" a valid statement ? PLO James Kuyper <jameskuyper@alumni.caltech.edu> - 2024-06-21 23:42 -0400
Re: is "x *= ++f * ++f" a valid statement ? PLO olcott <polcott333@gmail.com> - 2024-06-21 23:02 -0500
Re: is "x *= ++f * ++f" a valid statement ? PLO David Brown <david.brown@hesbynett.no> - 2024-06-22 13:09 +0200
Re: is "x *= ++f * ++f" a valid statement ? PLO olcott <polcott333@gmail.com> - 2024-06-22 07:40 -0500
Re: is "x *= ++f * ++f" a valid statement ? PLO Richard Damon <richard@damon-family.org> - 2024-06-22 09:56 -0400
Re: is "x *= ++f * ++f" a valid statement ? PLO "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2024-06-22 12:14 -0700
Re: is "x *= ++f * ++f" a valid statement ? PLO David Brown <david.brown@hesbynett.no> - 2024-06-22 16:52 +0200
Re: is "x *= ++f * ++f" a valid statement ? PLO olcott <polcott333@gmail.com> - 2024-06-22 11:27 -0500
Re: is "x *= ++f * ++f" a valid statement ? PLO Richard Damon <richard@damon-family.org> - 2024-06-22 13:20 -0400
Re: is "x *= ++f * ++f" a valid statement ? PLO Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2024-06-22 17:55 -0700
Re: is "x *= ++f * ++f" a valid statement ? PLO David Brown <david.brown@hesbynett.no> - 2024-06-23 14:46 +0200
Re: is "x *= ++f * ++f" a valid statement ? PLO James Kuyper <jameskuyper@alumni.caltech.edu> - 2024-06-22 15:48 -0400
Re: is "x *= ++f * ++f" a valid statement ? Richard Damon <richard@damon-family.org> - 2024-06-18 22:27 -0400
Re: is "x *= ++f * ++f" a valid statement ? olcott <polcott333@gmail.com> - 2024-06-22 21:51 -0500
Re: is "x *= ++f * ++f" a valid statement ? Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2024-06-22 21:51 -0700
Re: is "x *= ++f * ++f" a valid statement ? Richard Damon <richard@damon-family.org> - 2024-06-23 07:32 -0400
Re: is "x *= ++f * ++f" a valid statement ? olcott <polcott333@gmail.com> - 2024-06-23 07:59 -0500
Re: is "x *= ++f * ++f" a valid statement ? Richard Damon <richard@damon-family.org> - 2024-06-23 14:25 -0400
Re: is "x *= ++f * ++f" a valid statement ? olcott <polcott333@gmail.com> - 2024-06-23 14:18 -0500
Re: is "x *= ++f * ++f" a valid statement ? Richard Damon <richard@damon-family.org> - 2024-06-23 16:23 -0400
Re: is "x *= ++f * ++f" a valid statement ? David Brown <david.brown@hesbynett.no> - 2024-06-24 09:11 +0200
Re: is "x *= ++f * ++f" a valid statement ? what@tf.com (testuseri2p) - 2024-07-22 17:51 +0000
Re: is "x *= ++f * ++f" a valid statement ? Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2024-07-22 14:58 -0700
Re: is "x *= ++f * ++f" a valid statement ? James Kuyper <jameskuyper@alumni.caltech.edu> - 2024-07-22 21:57 -0400
Re: is "x *= ++f * ++f" a valid statement ? Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2024-07-22 20:40 -0700
Re: is "x *= ++f * ++f" a valid statement ? James Kuyper <jameskuyper@alumni.caltech.edu> - 2024-07-23 10:15 -0400
Re: is "x *= ++f * ++f" a valid statement ? Tim Rentsch <tr.17687@z991.linuxsc.com> - 2024-07-23 07:28 -0700
Re: is "x *= ++f * ++f" a valid statement ? Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2024-07-23 14:42 -0700
Re: is "x *= ++f * ++f" a valid statement ? Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2024-07-23 15:05 -0700
Re: is "x *= ++f * ++f" a valid statement ? Tim Rentsch <tr.17687@z991.linuxsc.com> - 2024-08-11 06:22 -0700
Re: is "x *= ++f * ++f" a valid statement ? Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2024-08-11 14:09 -0700
Re: is "x *= ++f * ++f" a valid statement ? Tim Rentsch <tr.17687@z991.linuxsc.com> - 2024-08-11 06:11 -0700
Re: is "x *= ++f * ++f" a valid statement ? Chris Ahlstrom <OFeem1987@teleworm.us> - 2024-08-11 09:25 -0400
Re: is "x *= ++f * ++f" a valid statement ? James Kuyper <jameskuyper@alumni.caltech.edu> - 2024-08-11 14:17 -0400
Re: is "x *= ++f * ++f" a valid statement ? Tim Rentsch <tr.17687@z991.linuxsc.com> - 2024-07-23 07:32 -0700
Re: is "x *= ++f * ++f" a valid statement ? Andrey Tarasevich <andreytarasevich@hotmail.com> - 2024-07-22 19:53 -0700
Re: is "x *= ++f * ++f" a valid statement ? James Kuyper <jameskuyper@alumni.caltech.edu> - 2024-07-23 10:01 -0400
csiph-web