On 2014-05-20, 9:11 PM, L. David Baron wrote:
On Wednesday 2014-05-21 11:51 +1200, Robert O'Callahan wrote:
On Wed, May 21, 2014 at 4:36 AM, Nicolas Silva <nical.si...@gmail.com>wrote:

Honestly, I don't mean to start a bikeshed about whether we should enforce
strict rules about this project-wise, because I know that people have
different tastes as to whether writing "Size" is vastly better than
"gfx::Size". But I'd like to encourage people to carefully make use of this
c++ feature, especially when the namespace in question is used a handful of
times in the file. I personally will be strict about it the reviews I give.


I don't think we should have rules that some reviewers enforce and others
don't. That makes life hard for everyone.

It's not clear to me how moving the "using namespace" declaration inside a
namespace helps. Won't most files in a unified build translation unit put
their declarations in the same namespace, negating any benefit?

Personally I find unified-build-related using-namespace errors are rare ---
I've not encountered one yet. I'm not sure they're worth attempting to
ameliorate.

I wonder if the problem is that we're overusing namespaces (i.e., we
have too many of them or put many classes at places too deeply
nested in the namespace hierarchy)?  Perhaps it makes sense to have
a guideline that names shouldn't feel overly verbose with only a
"using namespace mozilla"?  For example, that would suggest that
layers::Layer feeling redundant is a sign that Layer should instead
be directly in the mozilla namespace.

I think following such a guideline (and avoiding using declarations
of the inner namespaces) might help avoiding the various collision
problems we've hit.

The problem is that we're using nested namespaces with same names under them. C++ doesn't really provide a good mechanism to fix this problem, which means we have to create arbitrary restrictions on things such as where using namespaces go.

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.

Cheers,
Ehsan
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to