Path: csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: lvalues from the ternary op Date: Wed, 18 Jan 2017 09:59:42 -0800 Organization: None to speak of Lines: 44 Message-ID: References: <8737kned1h.fsf@bsb.me.uk> <8737klapvv.fsf@bsb.me.uk> <877f6alefh.fsf@bsb.me.uk> <37926c90-a12c-4854-8daf-bbbb6fb36dc0@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx02.eternal-september.org; posting-host="54f9ac688d108bee0d0cc30ece7b8d44"; logging-data="8524"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19E5A08ObZ0nQrFlBxvqx1A" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:fI/6HNQ9rdbwknZp6U+0HiDOO6A= sha1:5eAPFT5vNYrsyOVYivAXrz4G0WI= Xref: csiph.com comp.lang.c:102137 Manfred writes: > On 1/17/2017 8:09 AM, luser droog wrote: >> FWIW, my conception of an lvalue is slightly different. To me it >> is "a thing which can be on the left of an assignment operator". > This is the same definition that appeared in Dennis Ritchie's "C > Reference Manual" from Bell Labs. That is of course an incomplete definition. There are plenty of lvalues that can't appear on the LHS of an assignment, including array names and names of const-qualified objects. Nevertheless that is the origin of the "L" in "lvalue", and it's a good mnemonic. BTW, the 1974 and 1975 editions of the C Reference Manual both say: An object is a manipulatable region of storage; an lvalue is an expression referring to an object. An obvious example of an lvalue expression is an identifier. I'll check K&R1 later today. The C90, C99, and C11 standards all have different definitions of "lvalue", and the C90 and C99 definitions are incorrect. (It's difficult for a definition to be incorrect, but they managed.) The C90 definition implies that *ptr may or may not be an lvalue (a compile-time concept) depending on the run-time value of ptr. The C99 definition implies that 42 is an lvalue, and that evaluating it has undefined behavior. Obviously neither of these expressed the intent. In the original meaning, apparently from CPL (one of C's distant ancestors), an lvalue was a kind of value, resulting from evaluating an expression in a certain way. In C, an lvalue is not a value but a kind of expression. I've discussed this at greater length here: https://github.com/Keith-S-Thompson/the-flat-trantor-society/blob/master/005-c-standard-quibbles.md#what-is-an-lvalue or if the long URL is a problem: https://goo.gl/SwL2eK -- Keith Thompson (The_Other_Keith) kst-u@mib.org 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"