--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
I think we have made several mistakes when it comes to choosing namespace names, so thanks for bringing up this topic.
I suspect we would be better served by nesting namespaces as is now done in the base/ directory. See base::win:: for example.However, before you go and add chrome::browser::prerender::, we should probably stop and decide if we want to introduce chrome:: and browser::. Also, if applied to chrome/browser/net, we'd end up with chrome::browser::net::, and that would mean that code in chrome/browser/ may end up referring to code in chrome/browser/net using only the net:: namespace prefix (assuming that code were already within a 'namespace browser' section). It would be confusing to see reference to net:: that do not correspond to src/net/.
And maybe things like string16?
(I met resistance a long time ago when I tried putting string16 into base::.)
On Mon, Dec 6, 2010 at 11:58 AM, Darin Fisher <da...@chromium.org> wrote:I think we have made several mistakes when it comes to choosing namespace names, so thanks for bringing up this topic.+1, our namespace scheme is horribly inconsistent.I suspect we would be better served by nesting namespaces as is now done in the base/ directory. See base::win:: for example.However, before you go and add chrome::browser::prerender::, we should probably stop and decide if we want to introduce chrome:: and browser::. Also, if applied to chrome/browser/net, we'd end up with chrome::browser::net::, and that would mean that code in chrome/browser/ may end up referring to code in chrome/browser/net using only the net:: namespace prefix (assuming that code were already within a 'namespace browser' section). It would be confusing to see reference to net:: that do not correspond to src/net/.This is a very good point. I think I'm for having all toplevel directories (net, chrome, base) be their own namespace. Within the subdirectories, I'm not quite as sure how I feel. I guess I think that chrome/browser is large enough that chrome/subdir should be in chrome::subdir. Beyond that, I'm not sure we necessarily need to partition the namespace, except perhaps for chrome/browser/ui. I'm not as familiar here, so I'll refrain from commenting further on chrome/. But I'd like to reiterate that I think toplevel directories should be in toplevel namespaces. third_party is probably the only reasonable exception.
I don’t think it is special. We don’t do this for std::string, and if
we move string16 into a namespace, I don’t think we should do it
there, either.
I support having everything in base inside the base namespace with no
exceptions. The hardest things to move are string16 and the UTF
conversion routines since they're used so commonly. Probably the first
step on moving it is the "using" trick, but I don't think that means
we shouldn't hope to complete moving them someday and remove the
"using."
I think whether or not a subdirectory needs a namespace I think
depends on judgement. One example where it probably doesn't make sense
is chrome/browser/profile since these really belong in the
"chrome::browser" namespace and the're only a few simple files. One
place where it does make sense is in something larger like
chrome/browser/history that has many classes and help structs.
So to summarize, I think:
1. Toplevel dirs always use a namespace with their name.
2. If a subdirectory has a lot of files or whether your files to the
average committer, applying contemporary community standards, find,
taken as a whole, your files seem to be reasonably separable or a
cohesive whole [*], you should add a new namespace for it inside the
parent dir's namespace. Otherwise, use the parent dir's namespace.
3. Apply rule 2 recursively.
Brett
[*] I have been reading too many supreme court opinions.