by zzalpha · 10y ago · 0 comments
Much of that reasoning begins with understanding the types involved.
Of course, I would argue if you wanted to complain about this, you should begin by rejecting operator overloading, which IMO is far more dangerous in this regard than the auto keyword. At least with auto, there's a visual indicator that something "magical" is going on, and if you want to really know the return type, you navigate to the function or whatever to figure out what that type is.
With operator overloads, code that looks totally innocuous can end up doing extremely surprising things.
Personally I tend to not even use typedef's as often as other programmers do. I do it for really verbose stuff at times but I prefer always seeing what a type actually is in most cases. I find that it actually makes code more readable, though it does make refactoring slightly more annoying.
It's absolutely true that in an object instantiation, declaring the type twice (in the variable declaration and again in the construction) is repetitive. And it's a flaw in all object-based algol-style programming languages, which is why the var keyword was introduced to C#, and the diamond operator (while a half-assed solution for only part of the problem) was added to Java.
But that's just one narrow use case where I see this feature being worthwhile.
Write/Read using << and >>. Not a major problem, but it's weird and not very useful when you're trying to be C compatible.
You can index into a std::deque, but not a std::queue.
I'd also count the need for explicit in constructor declarations to be a similar kind of mistake.