Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | James Kuyper <jameskuyper@verizon.net> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: ->= |
| Date | 2015-11-27 20:28 -0500 |
| Organization | Self |
| Message-ID | <56590351.9020806@verizon.net> (permalink) |
| References | <n34i16$puk$1@speranza.aioe.org> <n34j05$tc0$1@dont-email.me> <31ca2f20-fac5-481e-8d90-cb50c4bd07f2@googlegroups.com> <56561CA9.3090703@verizon.net> <ad840d99-1797-4ae1-89af-a39c588d7e2f@googlegroups.com> |
On 11/27/2015 08:14 PM, John Bode wrote: > On Wednesday, November 25, 2015 at 2:40:25 PM UTC-6, James Kuyper wrote: >> On 11/25/2015 03:24 PM, John Bode wrote: >>> On Wednesday, November 25, 2015 at 9:12:43 AM UTC-6, Richard Heathfield wrote: >>>> On 25/11/15 14:53, glen herrmannsfeldt wrote: >>>>> In a recent post on linked list, there was the common notation: >>>>> >>>>> >>>>> p = p->next; >>>>> >>>>> Though I have written it many times, this time it occured to me >>>>> that there could have been a C operator ->= such that: >>>>> >>>>> p ->= next; >> ... >> >>> You'd probably want to add a `.=` operator as well. >> >> For consistency with the other compound assignment operators, the expression >> >> s .= member; >> >> would have to be equivalent to: >> >> s = s.member >> >> That would require that s.member have a type that's compatible with the >> type of s (6.5.16.1p1). How could that even be possible? > > Derp. > > You're correct, of course. > > Which introduces a bit of an assymetry. After thinking about it some more, > I'm not sure it would be that useful an operator. I mean, `->` is syntactic > sugar for `(*).`, but it's applicable to all struct member accesses; `->=` > would only be applicable in a very narrow domain (the member has to have > the same pointer type as the target). True - but it's a fairly common narrow domain. Any time you have a navigate a network of nodes of the same type connected by pointers, this operator could be convenient, and that's not an uncommon property for C data structures. Linked lists are just the simplest example of such a structure. Note: 6.5.16.2p3 would have to be revised slightly in a way that makes ->= a special case. That clause doesn't explicitly say that E2 is an expression, but that's clearly what was intended, and is hinted at by the 'E', and that wouldn't be the case for pstruct->=member. Also, defining it as equivalent to E1 = E1 op (E2) works for all of the existing compound assignment operators, but the parenthesis would have to be removed for ->=. I'm not sure that's sufficient reason to justify rejecting this idea, but it is a valid thing to object to.
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
->= glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2015-11-25 14:53 +0000
Re: ->= Richard Heathfield <rjh@cpax.org.uk> - 2015-11-25 15:12 +0000
Re: ->= James Kuyper <jameskuyper@verizon.net> - 2015-11-25 11:51 -0500
Re: ->= "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-11-25 09:49 -0800
Re: ->= supercat@casperkitty.com - 2015-11-25 09:55 -0800
Re: ->= John Bode <jfbode1029@gmail.com> - 2015-11-25 12:24 -0800
Re: ->= James Kuyper <jameskuyper@verizon.net> - 2015-11-25 15:40 -0500
Re: ->= John Bode <jfbode1029@gmail.com> - 2015-11-27 17:14 -0800
Re: ->= James Kuyper <jameskuyper@verizon.net> - 2015-11-27 20:28 -0500
Re: ->= "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-11-25 07:35 -0800
Re: ->= "Charles Richmond" <numerist@aquaporin4.com> - 2015-11-25 15:47 -0600
Re: ->= James Kuyper <jameskuyper@verizon.net> - 2015-11-25 17:04 -0500
Re: ->= Nobody <nobody@nowhere.invalid> - 2015-11-26 10:58 +0000
Re: ->= supercat@casperkitty.com - 2015-11-26 08:55 -0800
Re: ->= raltbos@xs4all.nl (Richard Bos) - 2015-11-26 00:48 +0000
Re: ->= Tim Rentsch <txr@alumni.caltech.edu> - 2015-11-27 14:15 -0800
Re: ->= supercat@casperkitty.com - 2015-11-27 14:26 -0800
Re: ->= BartC <bc@freeuk.com> - 2015-11-27 23:38 +0000
Re: ->= Keith Thompson <kst-u@mib.org> - 2015-11-27 19:37 -0800
Re: ->= Tim Rentsch <txr@alumni.caltech.edu> - 2015-11-28 06:35 -0800
Re: ->= Stephen Sprunk <stephen@sprunk.org> - 2015-11-27 17:51 -0600
Re: ->= Tim Rentsch <txr@alumni.caltech.edu> - 2015-11-28 06:53 -0800
Re: ->= glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2015-11-28 17:12 +0000
Re: ->= Keith Thompson <kst-u@mib.org> - 2015-11-28 10:26 -0800
Re: ->= glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2015-11-28 19:50 +0000
Re: ->= BartC <bc@freeuk.com> - 2015-11-28 19:14 +0000
Re: ->= supercat@casperkitty.com - 2015-11-28 11:48 -0800
Re: ->= glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2015-11-29 22:33 +0000
Re: ->= glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2015-11-28 20:18 +0000
Re: ->= Stephen Sprunk <stephen@sprunk.org> - 2015-11-28 18:15 -0600
Re: ->= glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2015-11-29 22:44 +0000
Re: ->= Stephen Sprunk <stephen@sprunk.org> - 2015-11-29 18:25 -0600
Re: ->= raltbos@xs4all.nl (Richard Bos) - 2015-11-30 10:21 +0000
Re: ->= Keith Thompson <kst-u@mib.org> - 2015-11-28 13:10 -0800
Re: ->= BartC <bc@freeuk.com> - 2015-11-28 22:12 +0000
Re: ->= raltbos@xs4all.nl (Richard Bos) - 2015-11-29 11:42 +0000
Re: ->= BartC <bc@freeuk.com> - 2015-11-29 14:24 +0000
Re: "->=" Eric Sosman <esosman@comcast-dot-net.invalid> - 2015-11-29 10:33 -0500
Re: "->=" BartC <bc@freeuk.com> - 2015-11-29 17:49 +0000
Re: ->= supercat@casperkitty.com - 2015-11-29 11:50 -0800
Re: ->= BartC <bc@freeuk.com> - 2015-11-29 22:37 +0000
Re: ->= Keith Thompson <kst-u@mib.org> - 2015-11-30 00:23 -0800
Re: ->= glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2015-11-29 23:00 +0000
Re: ->= Keith Thompson <kst-u@mib.org> - 2015-11-30 00:28 -0800
Re: ->= Rosario19 <Ros@invalid.invalid> - 2015-12-13 16:29 +0100
Re: ->= Eric Sosman <esosman@comcast-dot-net.invalid> - 2015-11-28 14:59 -0500
csiph-web