C++ static versus namespace

It really annoyed me that namespace-scope static declarations were deprecated in C++. Not because I have any particular love for the myriad meanings of "static", but because I have a dislike for namespaces, and anonymous namespaces in particular.

Why don't I like C++ namespaces? Partly because they're a less good solution than Java's packages, a more disciplined form of the same thing. Partly because I see people use them as a substitute for a class. Instead of implementing singleton the right way, they think they can get away with a namespace full of namespace-scope functions. Partly because – despite the braces – C++ programmers seem congenitally unable to indent them correctly, and not averse to having multiple namespaces in the same file, with the result that it's often hard to know where you are. (This, I guess, is just a symptom of the lack of discipline I mentioned by contrast to Java.)

Today I came across a practical reason to resist the language lawyers' complaints about using deprecated features, though:

hydrogen:/tmp$ cat > anon.cpp
namespace {
void unused1() {
static void unused2() {
hydrogen:/tmp$ g++-4.0 -W -Wall -pedantic -c anon.cpp
anon.cpp:6: warning: `void unused2()' defined but not used

I need all the help I can get to prevent the silting up of large codebases, so I won't be giving up on static for a while. I can't even see it's worth fixing g++(1) and submitting a patch, because I never did get anyone to even look at my last GCC patch, which warned about the "most vexing parse". (Yes, I spelled "Meyers" wrong.)