Path: csiph.com!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Tim Rentsch Newsgroups: comp.lang.c++ Subject: Re: is "x *= ++f * ++f" a valid statement ? Date: Sun, 11 Aug 2024 06:11:24 -0700 Organization: A noiseless patient Spider Lines: 59 Message-ID: <86sevbp5kz.fsf@linuxsc.com> References: <96127c8d8d204b7c3230828101bc2b6e@www.novabbs.org> <877cdchj2i.fsf@nosuchdomain.example.com> <86ttgg41yb.fsf@linuxsc.com> <8734nzhjkg.fsf@nosuchdomain.example.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Date: Sun, 11 Aug 2024 15:11:26 +0200 (CEST) Injection-Info: dont-email.me; posting-host="e27eccf1f18fd326d4b617bedae077c0"; logging-data="2872327"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19vfEBLQm2relEs2IyFGDS5mMFbajHKnbI=" User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux) Cancel-Lock: sha1:1zKTEaL+dUtEJzk0Yx0hKk+qcUg= sha1:0TGIaZF0jEJUNJk8duCcbRZfqTE= Xref: csiph.com comp.lang.c++:119795 Keith Thompson writes: > Tim Rentsch writes: > >> Keith Thompson writes: >> >>> James Kuyper 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? Even moreso than the C standard, the C++ standard needs to be read holistically. That may be a damning commentary on the quality of writing in the C++ standard, but I think it matches the reality. Given that, when confronted with a question like the ones you ask about the term "variable", a natural course of action to find answers to these questions might be to open the C++ standard in a PDF viewer, and use the viewer's search facility to look at places where the term in question is used. The more of those that can be looked at, the more likely it is that one will be able to discern answers to such questions. That's probably what I would do if I felt I needed a better understanding of, for example, what the term "variable" is supposed to mean.