Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | Keith Thompson <kst-u@mib.org> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: "lvalue" |
| Date | 2014-12-03 12:18 -0800 |
| Organization | None to speak of |
| Message-ID | <lnvblspjwa.fsf@nuthaus.mib.org> (permalink) |
| References | <lvalue-20141203103107@ram.dialup.fu-berlin.de> <m5nhhr$qda$1@dont-email.me> <m5nkqb$6qk$1@speranza.aioe.org> <m5nml1$gho$1@dont-email.me> |
buja <buja66@gmail.com> writes:
> On 12/03/2014 07:29 PM, jacob navia wrote:
>> Le 03/12/2014 18:34, buja a écrit :
>>> "An object is a named region of storage; an lvalue is an expression
>>> referring to an object."
>>
>> What a wonderful sentence. Simple, it explains everything.
>
> My point exactly.
> I know that K&R is not the current standard, but its description is just
> so much clearer than what the current standard has to say about this
> subject.
> And I am sure both K&R and the current standard intend to say exactly
> the same thing.
The problem with that simple sentence is that, if taken literally,
it implies that given this:
int *ptr = NULL;
the expression `*ptr` is not an lvalue, because it doesn't refer to
any object. You can argue that it obviously *means* that `*ptr` is
an lvalue only if you already have a good idea of what an lvalue is.
The addition of the word "potentially" in C11 fixed that problem,
by making it clear that `*ptr` is unconditionally an lvalue (a
compile-time concept) whether it happens to designate an object at
any particular moment during execution or not.
I don't suggest that the *intent* was ever unclear, or that any
compiler writer would have written code to determine at run time
whether `*ptr` is an lvalue or not. (I vaguely remember someone
being genuinely confused, thinking that lvalueness must actually
be determined at execution time; I don't remember the details.)
The problem is that the 1990 and 1999 standards did not correctly
express that intent. The 2011 standard isn't perfect (I'd be
happier with some explanation of what "potentially" means), but
it's closer than either of its predecessors.
Incidentally, an object needn't be named. A successful call to
malloc creates an anonymous object. The initial element of an array
can be referred to as `arr[0]`; is that a "name"? The definition of
"object" in the standard:
region of data storage in the execution environment, the contents
of which can represent values
is wordier, but frankly it needs to be.
The standard *needs* to use complex wording to define complex
concepts.
--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst>
Working, but not speaking, for JetHead Development, Inc.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: "lvalue" buja <buja66@gmail.com> - 2014-12-03 18:34 +0100
Re: "lvalue" James Kuyper <jameskuyper@verizon.net> - 2014-12-03 13:03 -0500
Re: "lvalue" jacob navia <jacob@spamsink.net> - 2014-12-03 19:29 +0100
Re: "lvalue" buja <buja66@gmail.com> - 2014-12-03 20:01 +0100
Re: "lvalue" Keith Thompson <kst-u@mib.org> - 2014-12-03 12:18 -0800
Re: "lvalue" Geoff <geoff@invalid.invalid> - 2014-12-03 12:20 -0800
Re: "lvalue" James Kuyper <jameskuyper@verizon.net> - 2014-12-03 15:29 -0500
Re: "lvalue" James Kuyper <jameskuyper@verizon.net> - 2014-12-03 21:48 -0500
Re: "lvalue" Keith Thompson <kst-u@mib.org> - 2014-12-04 08:20 -0800
Re: "lvalue" James Kuyper <jameskuyper@verizon.net> - 2014-12-04 11:44 -0500
Re: "lvalue" Keith Thompson <kst-u@mib.org> - 2014-12-04 11:41 -0800
Re: "lvalue" James Kuyper <jameskuyper@verizon.net> - 2014-12-04 14:50 -0500
Re: "lvalue" Keith Thompson <kst-u@mib.org> - 2014-12-03 23:40 -0800
Re: "lvalue" Tim Rentsch <txr@alumni.caltech.edu> - 2014-12-05 09:16 -0800
csiph-web