Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #170588
| From | Ben Bacarisse <ben.usenet@bsb.me.uk> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: Why does the -> operator exist ? |
| Date | 2023-06-27 15:56 +0100 |
| Organization | A noiseless patient Spider |
| Message-ID | <87fs6dosx5.fsf@bsb.me.uk> (permalink) |
| References | <trfLpf+N71iCzEwJm@bongo-ra.co> <s53rmj-dhr1.ln1@mail.home.palmen-it.de> <5GG1hY+aCvnXx5w2K@bongo-ra.co> |
Spiros Bousbouras <spibou@gmail.com> writes: > On Tue, 27 Jun 2023 15:01:16 +0200 > felix@palmen-it.de (Felix Palmen) wrote: >> * Spiros Bousbouras <spibou@gmail.com>: >> > I mean would it create an ambiguity if you could write s.field >> > both when s is a structure or union and when s is a pointer >> > to a structure or union ? >> >> Most likely no. >> >> So, my answer will be an opinion: In a language like C (with explicit >> resource management), pointers (taking them, dereferencing them) really >> *should* be explicit. For correct code, it's important to know whether >> you're dealing with a pointer or not. And the compiler gets a chance to >> tell you "careful, this doesn't have the type you seemed to expect". >> >> Yes, I know there are already a few exceptions. But looking at function >> pointers, they are special anyways, as functions themselves don't exist >> as types. And looking at the special evaluation of an array identifier >> as a pointer to its first element, well, this really created more than >> enough confusion, especially among beginners. > > A more similar exception is an expression a + b where b is an integer > type. a can be a pointer or an arithmetic type. This could have been outlawed and replaced by &a[b]. Of course, currently, a[b] is defined as *(a+b) so it relies on pointer arithmetic, but a[b] could have been defined independently so as to have a+b generate a warning. I don't think this was ever a consideration. -- Ben.
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Why does the -> operator exist ? Spiros Bousbouras <spibou@gmail.com> - 2023-06-27 09:12 +0000
Re: Why does the -> operator exist ? felix@palmen-it.de (Felix Palmen) - 2023-06-27 15:01 +0200
Re: Why does the -> operator exist ? Spiros Bousbouras <spibou@gmail.com> - 2023-06-27 14:09 +0000
Re: Why does the -> operator exist ? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2023-06-27 15:56 +0100
Re: Why does the -> operator exist ? Bart <bc@freeuk.com> - 2023-06-27 16:06 +0100
Re: Why does the -> operator exist ? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2023-06-27 18:01 +0100
Re: Why does the -> operator exist ? BGB <cr88192@gmail.com> - 2023-06-27 12:46 -0500
Re: Why does the -> operator exist ? fir <profesor.fir@gmail.com> - 2023-08-09 00:08 -0700
Re: Why does the -> operator exist ? fir <profesor.fir@gmail.com> - 2023-08-09 00:11 -0700
Re: Why does the -> operator exist ? fir <profesor.fir@gmail.com> - 2023-08-09 00:23 -0700
Re: Why does the -> operator exist ? Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2023-06-27 15:13 +0000
Re: Why does the -> operator exist ? Kaz Kylheku <864-117-4973@kylheku.com> - 2023-06-27 15:30 +0000
Re: Why does the -> operator exist ? Bart <bc@freeuk.com> - 2023-06-27 17:05 +0100
Re: Why does the -> operator exist ? Kaz Kylheku <864-117-4973@kylheku.com> - 2023-06-27 17:11 +0000
Re: Why does the -> operator exist ? BGB <cr88192@gmail.com> - 2023-06-27 10:54 -0500
Re: Why does the -> operator exist ? Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2023-06-27 12:23 -0700
Re: Why does the -> operator exist ? Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2023-06-27 15:33 -0600
Re: Why does the -> operator exist ? Spiros Bousbouras <spibou@gmail.com> - 2023-06-28 16:31 +0000
Re: Why does the -> operator exist ? Kaz Kylheku <864-117-4973@kylheku.com> - 2023-06-29 03:14 +0000
Re: Why does the -> operator exist ? Tim Rentsch <tr.17687@z991.linuxsc.com> - 2023-07-20 18:57 -0700
Re: Why does the -> operator exist ? Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2023-07-20 19:49 -0700
Re: Why does the -> operator exist ? Tim Rentsch <tr.17687@z991.linuxsc.com> - 2023-08-08 05:49 -0700
Re: Why does the -> operator exist ? Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2023-08-08 16:33 -0700
Re: Why does the -> operator exist ? Tim Rentsch <tr.17687@z991.linuxsc.com> - 2023-08-14 04:34 -0700
I love it... (Was: Why does the -> operator exist ?) gazelle@shell.xmission.com (Kenny McCormack) - 2023-08-14 12:41 +0000
Re: Why does the -> operator exist ? Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2023-08-14 15:10 -0700
Re: Why does the -> operator exist ? Phil Carmody <pc+usenet@asdf.org> - 2023-08-15 23:00 +0300
Re: Why does the -> operator exist ? Tim Rentsch <tr.17687@z991.linuxsc.com> - 2023-08-16 05:29 -0700
Re: Why does the -> operator exist ? Kaz Kylheku <864-117-4973@kylheku.com> - 2023-07-22 05:39 +0000
Re: Why does the -> operator exist ? Andrey Tarasevich <andreytarasevich@hotmail.com> - 2023-06-28 14:16 -0700
csiph-web