Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | BartC <bc@freeuk.com> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: lvalues from the ternary op |
| Date | 2016-09-28 01:35 +0100 |
| Organization | A noiseless patient Spider |
| Message-ID | <nsf37j$9ko$1@dont-email.me> (permalink) |
| References | <c8677aed-7589-4ba4-9aa0-8b20b00c0981@googlegroups.com> <8737kned1h.fsf@bsb.me.uk> <kfnk2dxc89h.fsf@x-alumni2.alumni.caltech.edu> <8737klapvv.fsf@bsb.me.uk> |
On 28/09/2016 00:23, Ben Bacarisse wrote: > Tim Rentsch <txr@alumni.caltech.edu> writes: >> The pattern is one that IME hardly ever comes up (not >> never, but certainly rarely). Adding the two &'s and one * is >> not very burdensome (and might be done using a macro to make the >> idiom stand out more, if that is desired). I don't see how a >> form like this generalizes to other cases (to emphasize, in C - >> in C++ it might be different). To me it looks like the two >> cost/benefit ratios weigh in favor of how C is now. So perhaps >> I don't understand what you consider the respective costs and >> benefits are in the two cases. It's for completeness. You allow A, *A, A.m, A[i] etc as both rvalues and lvalues. So why not a ternary op that can yield one of two potential lvalues? > I would have liked (in some alternate universe where the engineering > costs had already been incurred) to see the result of assignments be > lvalues (as they are in C++) as well as the result of a comma operator > (as it is in C++) and prefix -- and ++ (as they are in C++[1]). > > I don't really know how to evaluate the costs, but I would probably > still consider it a shame, even if I were sure it were so for sound > economic reasons. I looked at my language and that allows ternary ops (or equivalent) as the lhs of an assignment. But not the equivalent of the comma operator. Not until 20 minutes later anyway. When targeted at C, the results looked like this: Source lang: C (a|b|c) := d => (*(a?&b:&c)) = d; (++a; --b ;c) := d => (*((++a),(--b),&c)) = d; LHS expressions can be nested too. So the costs are not to do with the technical side. -- Bartc
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
lvalues from the ternary op luser droog <luser.droog@gmail.com> - 2016-09-25 16:12 -0700
Re: lvalues from the ternary op "James R. Kuyper" <jameskuyper@verizon.net> - 2016-09-25 19:58 -0400
Re: lvalues from the ternary op Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-09-26 01:10 +0100
Re: lvalues from the ternary op Tim Rentsch <txr@alumni.caltech.edu> - 2016-09-27 15:01 -0700
Re: lvalues from the ternary op Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-09-28 00:23 +0100
Re: lvalues from the ternary op BartC <bc@freeuk.com> - 2016-09-28 01:35 +0100
Re: lvalues from the ternary op "James R. Kuyper" <jameskuyper@verizon.net> - 2016-09-28 12:39 -0400
Re: lvalues from the ternary op BartC <bc@freeuk.com> - 2016-09-28 18:23 +0100
Re: lvalues from the ternary op Tim Rentsch <txr@alumni.caltech.edu> - 2016-10-08 15:37 -0700
Re: lvalues from the ternary op supercat@casperkitty.com - 2016-09-25 18:14 -0700
Re: lvalues from the ternary op BartC <bc@freeuk.com> - 2016-09-26 10:51 +0100
Re: lvalues from the ternary op luser droog <luser.droog@gmail.com> - 2016-09-26 12:42 -0700
csiph-web