Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #6734
| From | Miles Bader <miles@gnu.org> |
|---|---|
| Newsgroups | comp.lang.c++ |
| Subject | Re: "namespaces were a mistake" |
| Date | 2011-06-14 13:43 +0900 |
| Organization | NEC Electronics |
| Message-ID | <buowrgp2fc2.fsf@dhlpc061.dev.necel.com> (permalink) |
| References | (5 earlier) <slrniv4ogh.gtj.grahn+nntp@frailea.sa.invalid> <it45ki$ioc$7@reader1.panix.com> <slrnivbgoj.gtj.grahn+nntp@frailea.sa.invalid> <namespaces-20110613165149@ram.dialup.fu-berlin.de> <slrnivcqkc.gtj.grahn+nntp@frailea.sa.invalid> |
Jorgen Grahn <grahn+nntp@snipabacken.se> writes:
>> Danny Kalev, a member of the C++ standards committee between
>> 1997 and 2000, writes:
>>
>> »namespaces were a mistake«, see
>
> He's free to say so, but plenty of people I respect disagree.
Seriously. I _love_ namespaces, they're so convenient and painless
compared the stupid "make all your symbol names 5000 characters long
just in case" game we have to play in C (or the older "just don't care
and suffer tons of confusing and annoying conflicts" game)...
I also think his argument is flawed:
He argues that since using explicit prefixes is annoying, that most
people will resort to "using", and that this somehow eliminates the
safety offered by namespaces. However that simply isn't true, because
in reality, there can be _many_ namespaces used in a non-trivial
program, and the user gets to pick and choose -- in a very fine-grained
way (every file and block can have its own "using" statements) -- which
namespaces are referenced explicitly with prefixes, and which ones are
referenced implicity with "using" (and also when to import specific
symbols vs. all symbols in a namespace).
That gives the _user_ (er, "developer") the flexibility to choose which
potential conflicts there are, and which tradeoffs to make between
verbosity and potential conflict based on his specific circumstances.
In practice, this usually means one or two of the most important
namespaces _for a particular context_ are imported with "using", and
other less heavily-used namespaces are referenced explicitly (or
individual symbols imported from them). This is an extremely
convenient, and natural way to manage these name conflict issues.
Could namespaces be made better? I dunno, probably, in some way, but
certainly the basic concept seems quite sound, and quite useful.
-Miles
--
Immortality, n. A toy which people cry for, And on their knees apply for,
Dispute, contend and lie for, And if allowed Would be right proud
Eternally to die for.
Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar
Re: Anonymous namespace Jorgen Grahn <grahn+nntp@snipabacken.se> - 2011-06-09 11:26 +0000
Re: Anonymous namespace Ruben Safir <ruben@mrbrklyn.com> - 2011-06-10 04:12 +0000
Re: Anonymous namespace Michael Doubez <michael.doubez@free.fr> - 2011-06-10 01:49 -0700
Re: Anonymous namespace mrbrklyn <ceo.brooklyn@gmail.com> - 2011-06-10 10:34 -0700
Re: Anonymous namespace mrbrklyn <ceo.brooklyn@gmail.com> - 2011-06-10 10:45 -0700
Re: Anonymous namespace Michael Doubez <michael.doubez@free.fr> - 2011-06-12 00:01 -0700
Re: Anonymous namespace ruben safir <ruben@mrbrklyn.com> - 2011-06-13 04:08 +0000
Re: Anonymous namespace Michael Doubez <michael.doubez@free.fr> - 2011-06-13 08:43 -0700
Re: Anonymous namespace Jorgen Grahn <grahn+nntp@snipabacken.se> - 2011-06-10 18:27 +0000
Re: Anonymous namespace ruben safir <ruben@mrbrklyn.com> - 2011-06-13 05:02 +0000
Re: Anonymous namespace Jorgen Grahn <grahn+nntp@snipabacken.se> - 2011-06-13 07:58 +0000
Re: "namespaces were a mistake" (was: Anonymous namespace) Öö Tiib <ootiib@hot.ee> - 2011-06-13 09:56 -0700
Re: "namespaces were a mistake" (was: Anonymous namespace) Jorgen Grahn <grahn+nntp@snipabacken.se> - 2011-06-13 19:52 +0000
Re: "namespaces were a mistake" Miles Bader <miles@gnu.org> - 2011-06-14 13:43 +0900
Re: "namespaces were a mistake" Miles Bader <miles@gnu.org> - 2011-06-15 07:15 +0900
Re: "namespaces were a mistake" Jorgen Grahn <grahn+nntp@snipabacken.se> - 2011-06-15 12:01 +0000
Re: "namespaces were a mistake" (was: Anonymous namespace) drew@furrfu.invalid (Drew Lawson) - 2011-06-14 12:24 +0000
Re: "namespaces were a mistake" (was: Anonymous namespace) gwowen <gwowen@gmail.com> - 2011-06-14 06:00 -0700
Re: "namespaces were a mistake" (was: Anonymous namespace) Joshua Maurice <joshuamaurice@gmail.com> - 2011-06-14 14:10 -0700
Re: "namespaces were a mistake" Miles Bader <miles@gnu.org> - 2011-06-15 06:30 +0900
Re: Anonymous namespace Ruben Safir <ruben@mrbrklyn.com> - 2011-06-27 16:34 +0000
Re: Anonymous namespace Victor Bazarov <v.bazarov@comcast.invalid> - 2011-06-27 14:29 -0400
csiph-web