Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #101714
| From | Ben Bacarisse <ben.usenet@bsb.me.uk> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: lvalues from the ternary op |
| Date | 2017-01-14 02:15 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <87inpio082.fsf@bsb.me.uk> (permalink) |
| References | (2 earlier) <kfnk2dxc89h.fsf@x-alumni2.alumni.caltech.edu> <8737klapvv.fsf@bsb.me.uk> <o4jftg$vqf$1@gioia.aioe.org> <877f6alefh.fsf@bsb.me.uk> <kfn1sw6phwa.fsf@x-alumni2.alumni.caltech.edu> |
Tim Rentsch <txr@alumni.caltech.edu> writes: > Ben Bacarisse <ben.usenet@bsb.me.uk> writes: > >> Manfred <noname@invalid.add> writes: >> >>> On 9/28/2016 1:23 AM, Ben Bacarisse wrote: >>>> I consider special cases to be a sort of intellectual cost. >>> >>> I am 100% with you. >>> >>>> But my >>>> remark about it being a shame is not intended to be a considered >>>> weighing-up of hard engineering costs but simply a sad observation on >>>> there being yet another exception I would not have expected. If I did >>>> not know better, I would assume that that any expression that could >>>> reasonably be a lvalue would be an lvalue. >>> >>> Maybe the keyword here is "reasonably", which would point out that >>> what is reasonable for C++ is not for C. >> >> Yes, its a hopelessly woolly word. Almost as soon as I'd written it I >> thought: well, that doesn't say much, does it? >> >>> Here the C rationale appears to be "result of expressions are rvalues" >>> i.e. value-oriented, while the C++ rationale appears to be "result of >>> expressions are objects" i.e. more symbol-oriented. >> >> I can't comment on C++'s abstract model because I have not studied the >> standard, but, in C, expressions /evaluate/ to values (we could call >> them rvalues but that's probably unnecessary and the standard doesn't), >> whereas some syntactic forms of expression /are/ lvalues. So you are >> right that there is no kind of "value" (in C's abstract semantics) that >> could be used to denote objects. lvalues are simply expressions, not >> values, despite the name. >> >> But I don't think that gets us any closer to knowing what might or might >> not be "reasonable" in C. The C standard enumerates all the expression >> forms that are lvalues and, as in the case of x.y for example, it >> sometimes depends on whether one or other part of the expression is >> itself an lvalue. So there's no obvious reason that it could not say >> that a conditional expression is an lvalue if both arms are lvalue >> expressions. > > For what it's worth (and I know it may not be much), the current > choices in C make sense to me intuitively because I think of > "lvalue" as meaning roughly the same thing as "address". (Note: > in the sense of a machine address, not in the sense of C's & > operator.) All of C's lvalue expressions identify a particular > object, and the "lvalue" of that expression is the "address" of > the object. A bit-field member of a lvalue is an lvalue and need have no machine address in any literal sense. But I know what you mean -- lvalues are location designators. > Moreover there is a sense in which that is all they > do, is to identify a single object. Compound literals might seem > like an exception to that; I don't see them that way, probably > because I think of a compound literal as a declarationless > variable, and variables are of course lvalues. > > Seen from this perspective, a conditional expression would stand > out because there is (potentially) more than one object, and > there is more to the operator than just identifying an object. A half-way house between your view and mine would have the comma operator be an lvalue expression if the second part of it were one. Here there is only one object and there is not much more to the operator than there might be in other complex lvalue expressions. It would be a close analogue to the fact the (E) is a lvalue is E is one. I'm tempted to point to _Generic expressions as a precedent sine multiple objects may be involved, but the expression is doing nothing more but a type-based, compile-time selection of a location so it's not directly analogous. > Of course conditional expressions could be used to construct > lvalues, but that construction doesn't fit with my (admittedly > historical) view of what "lvalue" means. Yes, that was my view too, but then I learned Algol 68 and no one is ever quite the same after Algol 68. But, all in all, I think you are right that C's current choices are both simple and intuitive to anyone with a sound picture of what a typical computer is doing. What's happened to me is that my view of what a programming language should be has become more and more abstract so what might be going on in terms of addresses matters less and less with every passing decade. > To be clear, I don't mean to offer any sort of philosophical > truth here. I am just explaining my own views and reactions, in > case doing that might help someone form a useful mental model > for C's current choices. -- Ben.
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: lvalues from the ternary op Manfred <noname@invalid.add> - 2017-01-04 19:46 +0100
Re: lvalues from the ternary op supercat@casperkitty.com - 2017-01-04 11:08 -0800
Re: lvalues from the ternary op Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-01-04 21:10 +0000
Re: lvalues from the ternary op Keith Thompson <kst-u@mib.org> - 2017-01-04 13:48 -0800
Re: lvalues from the ternary op Ian Collins <ian-news@hotmail.com> - 2017-01-05 11:07 +1300
Re: lvalues from the ternary op Keith Thompson <kst-u@mib.org> - 2017-01-04 14:20 -0800
Re: lvalues from the ternary op supercat@casperkitty.com - 2017-01-04 14:41 -0800
Re: lvalues from the ternary op Keith Thompson <kst-u@mib.org> - 2017-01-04 15:21 -0800
Re: lvalues from the ternary op supercat@casperkitty.com - 2017-01-04 15:52 -0800
Re: lvalues from the ternary op Keith Thompson <kst-u@mib.org> - 2017-01-04 16:37 -0800
Re: lvalues from the ternary op Keith Thompson <kst-u@mib.org> - 2017-01-04 18:31 -0800
Re: lvalues from the ternary op Tim Rentsch <txr@alumni.caltech.edu> - 2017-01-13 17:26 -0800
Re: lvalues from the ternary op Keith Thompson <kst-u@mib.org> - 2017-01-13 17:49 -0800
Re: lvalues from the ternary op Tim Rentsch <txr@alumni.caltech.edu> - 2017-01-15 22:53 -0800
Re: lvalues from the ternary op Tim Rentsch <txr@alumni.caltech.edu> - 2017-01-13 17:08 -0800
Re: lvalues from the ternary op Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-01-14 02:15 +0000
Re: lvalues from the ternary op Tim Rentsch <txr@alumni.caltech.edu> - 2017-01-15 22:51 -0800
Re: lvalues from the ternary op luser droog <luser.droog@gmail.com> - 2017-01-16 23:09 -0800
Re: lvalues from the ternary op Manfred <noname@invalid.add> - 2017-01-18 14:51 +0100
Re: lvalues from the ternary op Keith Thompson <kst-u@mib.org> - 2017-01-18 09:59 -0800
Re: lvalues from the ternary op Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2017-01-18 13:12 -0500
Re: lvalues from the ternary op supercat@casperkitty.com - 2017-01-18 12:11 -0800
Re: lvalues from the ternary op Keith Thompson <kst-u@mib.org> - 2017-01-18 12:45 -0800
Re: lvalues from the ternary op supercat@casperkitty.com - 2017-01-18 14:07 -0800
Re: lvalues from the ternary op Keith Thompson <kst-u@mib.org> - 2017-01-18 14:40 -0800
Re: lvalues from the ternary op supercat@casperkitty.com - 2017-01-18 16:10 -0800
Re: lvalues from the ternary op Keith Thompson <kst-u@mib.org> - 2017-01-18 18:08 -0800
Re: lvalues from the ternary op supercat@casperkitty.com - 2017-01-19 06:44 -0800
Re: lvalues from the ternary op Keith Thompson <kst-u@mib.org> - 2017-01-19 08:40 -0800
Re: lvalues from the ternary op supercat@casperkitty.com - 2017-01-19 12:32 -0800
Re: lvalues from the ternary op supercat@casperkitty.com - 2017-01-20 06:01 -0800
Re: lvalues from the ternary op Keith Thompson <kst-u@mib.org> - 2017-01-20 08:15 -0800
Re: lvalues from the ternary op supercat@casperkitty.com - 2017-01-20 10:51 -0800
Re: lvalues from the ternary op Keith Thompson <kst-u@mib.org> - 2017-01-20 11:32 -0800
Re: lvalues from the ternary op supercat@casperkitty.com - 2017-01-20 13:41 -0800
Re: lvalues from the ternary op supercat@casperkitty.com - 2017-01-23 07:04 -0800
Re: lvalues from the ternary op Ike Naar <ike@iceland.freeshell.org> - 2017-01-23 17:59 +0000
Re: lvalues from the ternary op supercat@casperkitty.com - 2017-01-23 10:57 -0800
Re: lvalues from the ternary op Tim Rentsch <txr@alumni.caltech.edu> - 2017-01-31 08:45 -0800
Re: lvalues from the ternary op Keith Thompson <kst-u@mib.org> - 2017-01-31 09:13 -0800
Re: lvalues from the ternary op supercat@casperkitty.com - 2017-01-31 10:17 -0800
Re: lvalues from the ternary op Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-02-01 01:51 +0000
Re: lvalues from the ternary op supercat@casperkitty.com - 2017-02-01 14:24 -0800
Re: lvalues from the ternary op Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-02-02 03:07 +0000
Re: lvalues from the ternary op Tim Rentsch <txr@alumni.caltech.edu> - 2017-02-04 04:43 -0800
Re: lvalues from the ternary op supercat@casperkitty.com - 2017-02-04 08:01 -0800
Re: lvalues from the ternary op Tim Rentsch <txr@alumni.caltech.edu> - 2017-02-09 09:06 -0800
Re: lvalues from the ternary op supercat@casperkitty.com - 2017-02-09 11:56 -0800
Re: lvalues from the ternary op Tim Rentsch <txr@alumni.caltech.edu> - 2017-02-12 10:29 -0800
Re: lvalues from the ternary op supercat@casperkitty.com - 2017-02-12 13:43 -0800
Re: lvalues from the ternary op Tim Rentsch <txr@alumni.caltech.edu> - 2017-02-19 21:44 -0800
Re: lvalues from the ternary op supercat@casperkitty.com - 2017-02-20 08:15 -0800
Re: lvalues from the ternary op Tim Rentsch <txr@alumni.caltech.edu> - 2017-02-24 07:58 -0800
Re: lvalues from the ternary op supercat@casperkitty.com - 2017-02-24 10:00 -0800
Re: lvalues from the ternary op scott@slp53.sl.home (Scott Lurndal) - 2017-02-24 18:58 +0000
Re: lvalues from the ternary op supercat@casperkitty.com - 2017-02-24 13:03 -0800
Re: lvalues from the ternary op Keith Thompson <kst-u@mib.org> - 2017-02-24 14:11 -0800
Re: lvalues from the ternary op Keith Thompson <kst-u@mib.org> - 2017-02-24 12:42 -0800
Re: lvalues from the ternary op Keith Thompson <kst-u@mib.org> - 2017-02-24 13:49 -0800
Re: lvalues from the ternary op supercat@casperkitty.com - 2017-02-24 13:58 -0800
Re: lvalues from the ternary op Keith Thompson <kst-u@mib.org> - 2017-02-24 14:56 -0800
Re: lvalues from the ternary op supercat <flatfinger@casperkitty.com> - 2017-02-25 14:00 -0800
Re: lvalues from the ternary op Tim Rentsch <txr@alumni.caltech.edu> - 2017-02-25 09:23 -0800
Re: lvalues from the ternary op Tim Rentsch <txr@alumni.caltech.edu> - 2017-02-25 09:43 -0800
Re: lvalues from the ternary op Kelsey Bjarnason <kbjarnason@gmail.com> - 2017-02-01 22:47 -0800
Re: lvalues from the ternary op supercat@casperkitty.com - 2017-02-02 10:12 -0800
Re: lvalues from the ternary op Tim Rentsch <txr@alumni.caltech.edu> - 2017-02-04 07:51 -0800
Re: lvalues from the ternary op supercat@casperkitty.com - 2017-02-04 08:18 -0800
Re: lvalues from the ternary op Tim Rentsch <txr@alumni.caltech.edu> - 2017-02-09 08:58 -0800
Re: lvalues from the ternary op Tim Rentsch <txr@alumni.caltech.edu> - 2017-02-04 04:00 -0800
Re: lvalues from the ternary op Kelsey Bjarnason <kbjarnason@gmail.com> - 2017-02-04 09:35 -0800
Re: lvalues from the ternary op Tim Rentsch <txr@alumni.caltech.edu> - 2017-02-04 09:35 -0800
Re: lvalues from the ternary op Robert Wessel <robertwessel2@yahoo.com> - 2017-01-31 13:36 -0600
Re: lvalues from the ternary op supercat@casperkitty.com - 2017-01-31 12:23 -0800
Re: lvalues from the ternary op Tim Rentsch <txr@alumni.caltech.edu> - 2017-02-01 13:48 -0800
Re: lvalues from the ternary op Tim Rentsch <txr@alumni.caltech.edu> - 2017-01-31 08:53 -0800
Re: lvalues from the ternary op Manfred <noname@invalid.add> - 2017-01-19 14:10 +0100
Re: lvalues from the ternary op Tim Rentsch <txr@alumni.caltech.edu> - 2017-01-30 12:05 -0800
csiph-web