News for hackers. Stuff that matters.
Re:Clever code is probably the worst code you could write by haolez on Tuesday May 21, 2024 @06:48PM (#40434998)
I like C++, but I don't understand this tradition of keeping these annoying namespaces prefixed to everything. Just get rid of those std::, foo::bar::whatever::, etc from your code and make it more readable. Use the "use" clause. It's very rare for such names to be ambiguous in the same file, unless I'm missing some bigger picture here.
Re:Clever code is probably the worst code you could write by porphyra on Tuesday May 21, 2024 @07:01PM (#40435168)

    using namespace std;
is considered kinda bad since you don't want your namespace to be polluted with a bunch of std stuff. For example if you have `int count` lying around somewhere you'd want to be able to call `std::count` without fear of it being shadowed.
Re:Clever code is probably the worst code you could write by haolez on Tuesday May 21, 2024 @07:16PM (#40435345)
But ambiguity gives you readability. And if a "count" variable clashes with the function name, it's trivial for the compiler to catch this and warn you.

It's a matter of preference, but I'd still risk ambiguity and name collision, especially when you go beyond std:: (like boost stuff).

Re:Clever code is probably the worst code you could write by tialaramex on Tuesday May 21, 2024 @07:22PM (#40435428)
Because of bad design decisions, a whole pile of unrelated stuff lives in the std namespace, and the disambiguation probably isn't what you wanted, so this can silently cause surprises.
Re:Clever code is probably the worst code you could write by devnullbrain on Tuesday May 21, 2024 @07:19PM (#40435389)
It gives you readability. It's not what I'm used to, so it feels like reading French to me. Generally, if I see something without a namespace, it has a local scope.