Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #103501
| From | Ben Bacarisse <ben.usenet@bsb.me.uk> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: C Names and Scopes |
| Date | 2017-02-08 23:27 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <871sv88drc.fsf@bsb.me.uk> (permalink) |
| References | (5 earlier) <o7f70s$8co$1@dont-email.me> <871sv8ab6x.fsf@bsb.me.uk> <o7floc$3d1$1@dont-email.me> <87vask8kq0.fsf@bsb.me.uk> <o7g4q2$u6u$1@dont-email.me> |
BartC <bc@freeuk.com> writes: > On 08/02/2017 20:56, Ben Bacarisse wrote: >> BartC <bc@freeuk.com> writes: > >>> It may technically be possible because certain kinds of names belong >>> in particular contexts, but that doesn't make it any easier when >>> confronted with code that makes use of that and that can throw you, >>> because you weren't even aware that something was possible: >>> >>> struct A A; >> >> How could that throw anyone (other than the silly names)? If I see >> >> struct node node; >> >> it is clear what's going on (provided I have even the most basic >> understanding of C's struct syntax). On the flip side, your way will >> surprise people who expect to be able to call their variable X even when >> X is used for some totally different kind of name. > > I don't know what you mean by 'my way' unless it's not to allow > overloading of any names in the same scope. I intened to suggest whatever it was you think C should have done. In this case putting struct tags and object names into the same namespace. > And do people really expect to use X for different things like that? If people don't do this the issue you worry about above (readers being surprised) by the use simply won't happen. If it does happen (so you are right to wonder if readers will surprised) then presumably it's because people expected to be a able to do it. <snpi> >>> or: >>> >>> Point p; >>> struct Point q; >> >> How is that going to be clearer if the struct tag can't share a name >> with the type? Using different names won't stop the code being odd, and >> it's obvious that something very odd is going on. By being able to use >> the same name the strangeness is brought to the fore so I'd call that an >> advantage in this case. > > This doesn't make sense. You're advocating justifying an odd feature > because using it highlights the fact that it's odd and gets people to > look twice? Having about not having it at all? Then there would be no > need. I think you need to explain what the code above is doing. To me it defines two obviously very closely related kinds of thing in two different ways. If typedef names and struct tags can't be the same the programmer would have written something else but I can't know what that would be because I can't know the intent. Maybe they would have written Point2D p; struct Vector2D q; Now the only oddity why one is a struct and the other is not, but it's also clear that the error in your example is not down to C's naming permission but that bad names were chosen. But if a Point and a struct Point are indeed the same thing then I want your code to stay as it is and look odd -- as odd as possible -- because it needs correcting to either Point p, q; or struct Point p, q; to make that clear. Obliging the programmer to use slightly different names won't make this odd code ant clearer. In fact it might hide how very off it is by suggesting that maybe the two things are different. <snip> -- Ben.
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
C Names and Scopes BartC <bc@freeuk.com> - 2017-02-08 02:13 +0000
Re: C Names and Scopes David Brown <david.brown@hesbynett.no> - 2017-02-08 10:09 +0100
Re: C Names and Scopes mark.bluemel@gmail.com - 2017-02-08 02:37 -0800
Re: C Names and Scopes BartC <bc@freeuk.com> - 2017-02-08 11:07 +0000
Re: C Names and Scopes fir <profesor.fir@gmail.com> - 2017-02-08 09:03 -0800
Re: C Names and Scopes BartC <bc@freeuk.com> - 2017-02-08 17:19 +0000
Re: C Names and Scopes fir <profesor.fir@gmail.com> - 2017-02-08 09:42 -0800
Re: C Names and Scopes David Brown <david.brown@hesbynett.no> - 2017-02-08 12:08 +0100
Re: C Names and Scopes Moai <penultimategrill@gmail.com> - 2017-02-08 19:16 -0500
Re: C Names and Scopes David Brown <david.brown@hesbynett.no> - 2017-02-09 01:32 +0100
Re: C Names and Scopes Tim Rentsch <txr@alumni.caltech.edu> - 2017-02-09 08:18 -0800
Re: C Names and Scopes Jerry Stuckle <jstucklex@attglobal.net> - 2017-02-09 12:06 -0500
Re: C Names and Scopes BartC <bc@freeuk.com> - 2017-02-08 10:51 +0000
Re: C Names and Scopes Thiago Adams <thiago.adams@gmail.com> - 2017-02-08 03:11 -0800
Re: C Names and Scopes BartC <bc@freeuk.com> - 2017-02-08 11:39 +0000
Re: C Names and Scopes BartC <bc@freeuk.com> - 2017-02-08 12:06 +0000
Re: C Names and Scopes BartC <bc@freeuk.com> - 2017-02-08 13:31 +0000
Re: C Names and Scopes BartC <bc@freeuk.com> - 2017-02-08 13:40 +0000
Re: C Names and Scopes Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-02-08 16:39 +0000
Re: C Names and Scopes BartC <bc@freeuk.com> - 2017-02-08 17:51 +0000
Re: C Names and Scopes Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-02-08 20:56 +0000
Re: C Names and Scopes BartC <bc@freeuk.com> - 2017-02-08 22:08 +0000
Re: C Names and Scopes Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-02-08 23:27 +0000
Re: C Names and Scopes David Brown <david.brown@hesbynett.no> - 2017-02-08 13:41 +0100
Re: C Names and Scopes Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-02-08 14:32 +0000
Re: C Names and Scopes supercat@casperkitty.com - 2017-02-08 07:28 -0800
Re: C Names and Scopes BartC <bc@freeuk.com> - 2017-02-08 20:12 +0000
Re: C Names and Scopes Keith Thompson <kst-u@mib.org> - 2017-02-08 12:38 -0800
Re: C Names and Scopes BartC <bc@freeuk.com> - 2017-02-08 21:54 +0000
Re: C Names and Scopes BartC <bc@freeuk.com> - 2017-02-08 22:40 +0000
Re: C Names and Scopes BartC <bc@freeuk.com> - 2017-02-09 18:48 +0000
Re: C Names and Scopes Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-02-09 19:53 +0000
Re: C Names and Scopes Keith Thompson <kst-u@mib.org> - 2017-02-09 12:25 -0800
Re: C Names and Scopes Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-02-09 21:27 +0000
Re: C Names and Scopes Keith Thompson <kst-u@mib.org> - 2017-02-09 13:57 -0800
Re: C Names and Scopes David Brown <david.brown@hesbynett.no> - 2017-02-13 10:54 +0100
Re: C Names and Scopes BartC <bc@freeuk.com> - 2017-02-10 00:26 +0000
Re: C Names and Scopes Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-02-10 00:42 +0000
Re: C Names and Scopes BartC <bc@freeuk.com> - 2017-02-10 01:03 +0000
Re: C Names and Scopes Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-02-10 01:49 +0000
Re: C Names and Scopes BartC <bc@freeuk.com> - 2017-02-10 12:31 +0000
Re: C Names and Scopes Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-02-10 23:48 +0000
Re: C Names and Scopes supercat@casperkitty.com - 2017-02-10 16:06 -0800
Re: C Names and Scopes Keith Thompson <kst-u@mib.org> - 2017-02-10 16:22 -0800
Re: C Names and Scopes supercat@casperkitty.com - 2017-02-12 09:17 -0800
Re: C Names and Scopes Tim Rentsch <txr@alumni.caltech.edu> - 2017-02-15 16:26 -0800
Re: C Names and Scopes Keith Thompson <kst-u@mib.org> - 2017-02-09 17:56 -0800
Re: C Names and Scopes supercat@casperkitty.com - 2017-02-10 07:42 -0800
Re: C Names and Scopes Keith Thompson <kst-u@mib.org> - 2017-02-10 08:44 -0800
Re: C Names and Scopes supercat@casperkitty.com - 2017-02-10 09:25 -0800
Re: C Names and Scopes Jerry Stuckle <jstucklex@attglobal.net> - 2017-02-10 16:43 -0500
Re: C Names and Scopes supercat@casperkitty.com - 2017-02-10 14:04 -0800
Re: C Names and Scopes BartC <bc@freeuk.com> - 2017-02-10 22:52 +0000
Re: C Names and Scopes Andrey Tarasevich <andreytarasevich@hotmail.com> - 2017-02-10 15:10 -0800
Re: C Names and Scopes Tim Rentsch <txr@alumni.caltech.edu> - 2017-02-15 16:31 -0800
Re: C Names and Scopes BartC <bc@freeuk.com> - 2017-02-09 23:09 +0000
Re: C Names and Scopes Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-02-09 23:36 +0000
Re: C Names and Scopes BartC <bc@freeuk.com> - 2017-02-10 00:19 +0000
Re: C Names and Scopes Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-02-10 00:38 +0000
Re: C Names and Scopes BartC <bc@freeuk.com> - 2017-03-04 01:23 +0000
Re: C Names and Scopes jameskuyper@verizon.net - 2017-03-03 18:23 -0800
Re: C Names and Scopes GOTHIER Nathan <nathan.gothier@gmail.com> - 2017-03-04 14:42 +0100
Re: C Names and Scopes "James R. Kuyper" <jameskuyper@verizon.net> - 2017-03-04 11:02 -0500
Re: C Names and Scopes GOTHIER Nathan <nathan.gothier@gmail.com> - 2017-03-04 23:35 +0100
Re: C Names and Scopes Malcolm McLean <malcolm.mclean5@btinternet.com> - 2017-03-04 14:50 -0800
Re: C Names and Scopes Richard Heathfield <rjh@cpax.org.uk> - 2017-03-05 13:39 +0000
Re: C Names and Scopes GOTHIER Nathan <nathan.gothier@gmail.com> - 2017-03-05 15:10 +0100
Re: C Names and Scopes Richard Heathfield <rjh@cpax.org.uk> - 2017-03-05 14:34 +0000
Re: C Names and Scopes Keith Thompson <kst-u@mib.org> - 2017-03-05 19:25 -0800
Re: C Names and Scopes raltbos@xs4all.nl (Richard Bos) - 2017-03-06 09:37 +0000
Re: C Names and Scopes Richard Heathfield <rjh@cpax.org.uk> - 2017-03-06 10:34 +0000
Re: C Names and Scopes James Kuyper <jameskuyper@verizon.net> - 2017-03-06 07:23 -0500
Re: C Names and Scopes GOTHIER Nathan <nathan.gothier@gmail.com> - 2017-03-06 14:26 +0100
Re: C Names and Scopes Keith Thompson <kst-u@mib.org> - 2017-03-04 11:52 -0800
Re: C Names and Scopes BartC <bc@freeuk.com> - 2017-03-04 20:13 +0000
Re: C Names and Scopes BartC <bc@freeuk.com> - 2017-03-04 20:17 +0000
Re: C Names and Scopes Keith Thompson <kst-u@mib.org> - 2017-03-04 12:38 -0800
Re: C Names and Scopes jameskuyper@verizon.net - 2017-03-04 13:50 -0800
Re: C Names and Scopes BartC <bc@freeuk.com> - 2017-03-04 22:37 +0000
Re: C Names and Scopes jameskuyper@verizon.net - 2017-03-04 16:15 -0800
Re: C Names and Scopes BartC <bc@freeuk.com> - 2017-03-05 00:31 +0000
Re: C Names and Scopes jameskuyper@verizon.net - 2017-03-04 16:47 -0800
Re: C Names and Scopes BartC <bc@freeuk.com> - 2017-03-05 01:42 +0000
Re: C Names and Scopes jameskuyper@verizon.net - 2017-03-04 19:20 -0800
Re: C Names and Scopes Keith Thompson <kst-u@mib.org> - 2017-03-05 01:40 -0800
csiph-web