spu...@isnotyourbuddy.co.uk wrote:
> I disagree. I find <namespace>:: peppered all over the code annoying and messy.
> There's a reason the "using" command was included as part of the standard.
The "std::" prefix makes the code more readable because it acts as a visual
clue that something from the standard library is being used there. With a
quick visual scan you can immediately see where standard library utilities
are being used. Without the prefix it requires a deeper look, and a deeper
experience and knowledge of what's from the standard library and what isn't.
The "std::" prefix also conveys information that makes it easier to
undestand what code is doing, or gives you immediately a hint of where to
look. For example, suppose you see a line of code like this:
if(equal(a, b, c))
what does that mean? Without further knowledge it's hard to say. Is that
"equal()" function some custom function (or even macro) somewhere else
in the code? Maybe it's declared in some header file? An IDE would tell
you quickly, but you don't always have an IDE at hand.
The name alone also doesn't tell you much about what it's doing. Maybe
it's comparing if all three parameters are equal? What is the type of
the parameters?
However, consider if the line had been written like this instead:
if(std::equal(a, b, c))
that change alone conveys an enormous amount of useful information,
which you can discern without having to see anything else in the code.
You immediately know that it's a standard library function. Even if
you don't know what it does, you immediately know where to look for it.
If you do know what std::equal() does, you also know what it's doing
there and, moreover, what kind of variables a, b and c are.
(Particulary, they are iterators of some kind.)
The line of code did not become harder to read and understand by the
addition of the prefix, but the exact opposite.