Daniel T. said:
The compiler informs me of the issue and I disambiguate the code.
That is exactly why I think putting std:: in front of all the symbols is
a bad idea. Pre-namespace, each library had to prepend every function
and type in its code with some "unique" symbol, this had to be typed
every-time one used any type or symbol from that library.
The whole point of the namespace mechanism is to remove the need for
those warts,
I think the point is to give the programmer a reasonable way to avoid name
collisions. Namespaces only remove warts if you take the unsafe appoach of
automatically placing a using clause at the top of each of your programs.
Doing this is the functional equivalent of using neither warts nor
namespaces.
so why on earth would you voluntarily put them right back
In old fashioned C interfaces we had to put warts on the names to prevent
collisions. For instance:
mylib_open();
mylib_close();
As you point out, it isn't a great step forward to have to type
mylib:
pen();
mylib::close();
However, there was never a practice of writing
std_vector<double> x;
std_cout << y;
Hence, putting potentially hundreds of names in your namespace by writing
using namespace std;
seems kind of crazy, at least for new code. (I could see it as a measure for
migrating legacy code.) In effect, namespaces allow us to put warts on all
the standard library names which, given their sheer number, seems like a
damned good idea to me.
I personally don't mind writing
mylib:
pen();
That, together with a telling header such as
#include "mylib/mylib.h"
gives the reader of the code a pretty good idea of where things are coming
from. And if the namespace is too long there is a mechanism to create an
alias.
As I show above, I'm not kidding.
Now I understand the disconnect: we have radically different ideas about the
purpose of namespaces.