Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | nick_keighley_nospam@hotmail.com |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: What about namespaces ? |
| Date | 2012-04-04 00:49 -0700 |
| Organization | http://groups.google.com |
| Message-ID | <24515214.1453.1333525755303.JavaMail.geo-discussion-forums@ynil13> (permalink) |
| References | <jleflk$kv0$1@speranza.aioe.org> <namespaces-20120404002106@ram.dialup.fu-berlin.de> <jlg0dn$re2$1@speranza.aioe.org> <jjes49-hjp.ln1@wilbur.25thandClement.com> |
On Wednesday, April 4, 2012 12:44:19 AM UTC+1, William Ahern wrote:
> Rui Maciel <rui.maciel@gmail.com> wrote:
> > Stefan Ram wrote:
> > > Rui Maciel <rui.maciel@gmail.com> writes:
> > >>So, with this in mind, what are your thoughts on the idea of introducing
> > >>namespaces to the C programming language? Would it be a bad idea?
> > >
> > > In this regard, one can also read the paragraph starting with
> > >
> > > »The sad conclusion that namespaces were a mistake.«
> > >
> > > http://www.informit.com/guides/content.aspx?g=cplusplus&seqNum=286
>
> > The thesis presented in that article is that "namespaces were a mistake"
> > due to the following two reasons:
> > - programmers may use namespaces in a way that the author doesn't like
> <snip>
> > The first reason is a bit silly while the second one doesn't apply to the C
> > programming language.
>
> I think you understate this. What he showed wasn't what "programmers" did,
> but how actual standards writers and implementors abused and diminished
> namespaces.
>
> Namespaces don't prevent name clashing. As regards naming conflicts,
> namespaces are hardly any different than prefixing and undercores. That's
> because everybody prefers to use (and reuse) short, easy to remember
> prefixes--like xml or dns or socket or, in the C++ case, "std". The
> alternative is to go the Java route, incorporating global namespaces a la
> DNS or X.500. One leaves you, effectively, with the status quo; the other
> leads somewhere many people don't want to go.
I'm not sure namespaces quite leave you at status quo. You have the option of using a using directive- and using short names
using my_wonderful_sockets;
socket.open();
or ommitting the using directive and having long names
my_wonderful_sockets::socket.open();
but also (I understand) having some sort of namespace alias
sock::socket.open();
If sock:: turns out to collide you can fiddle with aliases and using directives until you get the right library.
Even using the using directive you've eliminated all those other socket.open() versions that might confuse things.
C++'s problem might be that the standard libary is a pretty poor example of how to partition a namespace! ie. not to partition it at all. The reason they tell you not to stick "using std;" in, is because it stuffs thousands of names into your namespace. "using" wouldn't be such bad news with decently sized namespaces.
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
What about namespaces ? Rui Maciel <rui.maciel@gmail.com> - 2012-04-03 10:25 +0100
Re: What about namespaces ? "BartC" <bc@freeuk.com> - 2012-04-03 11:20 +0100
Re: What about namespaces ? Ian Collins <ian-news@hotmail.com> - 2012-04-03 22:29 +1200
Re: What about namespaces ? "BartC" <bc@freeuk.com> - 2012-04-03 12:38 +0100
Re: What about namespaces ? Keith Thompson <kst-u@mib.org> - 2012-04-03 12:19 -0700
Re: What about namespaces ? "BartC" <bc@freeuk.com> - 2012-04-03 20:57 +0100
Re: What about namespaces ? gordonb.9sh3w@burditt.org (Gordon Burditt) - 2012-04-03 06:23 -0500
Re: What about namespaces ? Rui Maciel <rui.maciel@gmail.com> - 2012-04-03 19:54 +0100
Re: What about namespaces ? Malcolm McLean <malcolm.mclean5@btinternet.com> - 2012-04-03 12:18 -0700
Re: What about namespaces ? jgharston <jgh@arcade.demon.co.uk> - 2012-04-03 13:09 -0700
Re: What about namespaces ? Rui Maciel <rui.maciel@gmail.com> - 2012-04-03 19:54 +0100
Re: What about namespaces ? Rui Maciel <rui.maciel@gmail.com> - 2012-04-03 19:54 +0100
Re: What about namespaces ? 88888 Dihedral <dihedral88888@googlemail.com> - 2012-04-03 06:49 -0700
Re: What about namespaces ? Robert Wessel <robertwessel2@yahoo.com> - 2012-04-03 11:10 -0500
Re: What about namespaces ? Rui Maciel <rui.maciel@gmail.com> - 2012-04-03 20:12 +0100
Re: What about namespaces ? Ian Collins <ian-news@hotmail.com> - 2012-04-04 07:20 +1200
Re: What about namespaces ? Fritz Wuehler <fritz@spamexpire-201204.rodent.frell.theremailer.net> - 2012-04-03 20:58 +0200
Re: What about namespaces ? Rui Maciel <rui.maciel@gmail.com> - 2012-04-03 21:05 +0100
Re: What about namespaces ? "BartC" <bc@freeuk.com> - 2012-04-03 21:33 +0100
Re: What about namespaces ? William Ahern <william@wilbur.25thandClement.com> - 2012-04-03 12:05 -0700
Re: What about namespaces ? James Kuyper <jameskuyper@verizon.net> - 2012-04-03 15:50 -0400
Re: What about namespaces ? Rui Maciel <rui.maciel@gmail.com> - 2012-04-03 21:27 +0100
Re: What about namespaces ? Malcolm McLean <malcolm.mclean5@btinternet.com> - 2012-04-03 14:40 -0700
Re: What about namespaces ? jgk@panix.com (Joe keane) - 2012-04-11 20:56 +0000
Re: What about namespaces ? Ben Pfaff <blp@cs.stanford.edu> - 2012-04-11 14:46 -0700
Re: What about namespaces ? jgk@panix.com (Joe keane) - 2012-04-11 23:03 +0000
Re: What about namespaces ? jgk@panix.com (Joe keane) - 2012-04-13 00:40 +0000
Re: What about namespaces ? Keith Thompson <kst-u@mib.org> - 2012-04-12 18:56 -0700
Re: What about namespaces ? "BartC" <bc@freeuk.com> - 2012-04-13 13:20 +0100
Re: What about namespaces ? Keith Thompson <kst-u@mib.org> - 2012-04-13 13:43 -0700
Re: What about namespaces ? jgk@panix.com (Joe keane) - 2012-04-15 16:46 +0000
Re: What about namespaces ? Martin Ambuhl <mambuhl@earthlink.net> - 2012-04-21 04:38 -0400
Re: What about namespaces ? "BartC" <bc@freeuk.com> - 2012-04-21 16:44 +0100
Re: What about namespaces ? "BartC" <bc@freeuk.com> - 2012-04-11 23:01 +0100
Re: What about namespaces ? jgk@panix.com (Joe keane) - 2012-04-13 21:04 +0000
Re: What about namespaces ? lawrence.jones@siemens.com - 2012-04-11 22:09 -0400
Re: What about namespaces ? Nomen Nescio <nobody@dizum.com> - 2012-04-12 10:55 +0200
Re: What about namespaces ? Rui Maciel <rui.maciel@gmail.com> - 2012-04-04 00:17 +0100
Re: What about namespaces ? William Ahern <william@wilbur.25thandClement.com> - 2012-04-03 16:44 -0700
Re: What about namespaces ? nick_keighley_nospam@hotmail.com - 2012-04-04 00:49 -0700
Re: What about namespaces ? Ian Collins <ian-news@hotmail.com> - 2012-04-04 14:54 +1200
Re: What about namespaces ? Ian Collins <ian-news@hotmail.com> - 2012-04-04 15:43 +1200
Re: What about namespaces ? Ian Collins <ian-news@hotmail.com> - 2012-04-04 16:06 +1200
Re: What about namespaces ? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-04-04 04:37 +0100
Re: What about namespaces ? Kaz Kylheku <kaz@kylheku.com> - 2012-04-04 18:43 +0000
Re: What about namespaces ? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-04-05 01:43 +0100
Re: What about namespaces ? "io_x" <a@b.c.invalid> - 2012-04-04 09:32 +0200
Re: What about namespaces ? Tim Rentsch <txr@alumni.caltech.edu> - 2012-04-05 11:22 -0700
Re: What about namespaces ? Rui Maciel <rui.maciel@gmail.com> - 2012-04-05 21:04 +0100
Re: What about namespaces ? Kaz Kylheku <kaz@kylheku.com> - 2012-04-06 01:10 +0000
csiph-web