On 2014-05-20, 10:00 PM, Joshua Cranmer 🐧 wrote:
On 5/20/2014 8:37 PM, Ehsan Akhgari wrote:
FWIW, I argued against nested namespaces a few years ago (couldn't
find a link to it through Google unfortunately) and people let me
"win" that battle by allowing me to edit the coding style to prohibit
nested namespoaces in most cases
<https://developer.mozilla.org/en-US/docs/Mozilla/Developer_guide/Coding_Style#Namespaces>,
but unfortunately we never adhered to this rule in practice, and these
days three level nested namespaces are pretty common in the code base.
We're just bending C++ in a way that it's not quite comfortable with
here.
How about adding the rule "all new namespaces must be approved by
<insert specific top-level superreviewer here>", just like all new
top-level directories need to be explicitly approved? If we could get
reviewers to enforce that, it would hopefully cut down on people using
outlandishly long namespaces.
I don't think that will work. IIRC I approached some module owners
about this back in the day and they explicitly told me that they don't
care and asked me to fix the rest of the places where we use nested
namespaces, and I ended up giving up on the whole idea.
I think there are valid reasons to have a two-level namespace (e.g.,
mozilla::mailnews [1]), but I find it deathly hard to justify going any
deeper.
[1] Actually, I would probably prefer mozilla::comm had
mozilla::mailnews not already had precedent when I started using C++
namespaces. :-)
See, this is the problem! Everyone thinks that it's reasonable to add
their own nested namespaces, and they're right as long as they don't
look at the big picture. As long as we allow any code to #include any
other code, this is a slippery slope.
Honestly, speaking as the person who did the majority of the work to
give us unified builds, and presumably dealt with the most of this issue
while doing so, this is not a very important problem, and it's uncommon
enough that I don't think it warrants an effort to get a handle on our
namespace usage or add stricter review requirements.
Cheers,
Ehsan
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform