Problem arises when we find "y" deep in a function, searches for its definition, and encounters "auto y = std::move(x);". Now we have to know the type of x, and if x is defined similarly, up the chain. Not fun.
foo(A * x) doesn't pose similar problem. On the other hand, if I write
auto bar = foo(A*x);
Then we can have the same problem (esp. if foo is a templated function).
To be honest, I just hover my mouse over 'bar' to get the type, and I name 'bar' something more meaningful than bar. "ball_covariance", "movie_recommendations", or whatever that matrix multiplication is computing for me.
I wrung my hands when I started using 'auto' but none of the worries came to pass.
But yes, if the code is unreadable without a type, add a type. No biggie, and no one is suggesting inflexible application of rules (always use 'auto' if it is possible). The same way when I might call
foo(boo(x));
and it is not clear, I'll explicitly name the output of boo in a temporary variable:
auto robot_velocity = boo(x);
auto robot_covariance = foo(robot_velocity);
I have to say, I find the last the most unreadable. I almost never care deeply about the type, and care deeply about the meaning.
Interestingly, no one worries about typedef. typedefs wrapped around intricate collections (map of lists of dictionary of arrays) can effectively obscure what the underlying types are just as much as auto. But again, mouse hover, CTRL+I, or whatever your IDE supplies pretty much makes that a non-issue as well.
edit: the problem you are describing is due to too big a function, not 'auto'.
> Problem arises when we find "y" deep in a function, searches for its definition, and encounters "auto y = std::move(x);".
This is gun control applied to computer languages.
The solution is not to ban a useful feature that would ordinarily aid the understandability of code, the solution is to not abuse such features to write gibberish.
People can write spaghetti code with any syntax you provide them, even Python.
There should be no such thing as deep in a function, or at least not as deep as you mean (i.e. so deep that you can't figure out what y is): that would in all likelyhood mean your function is too long, has too much responsabilities. Good functions are short and composed of other short functions, they should be short enough so that you can read them through without ever having to wonder 'wtf is this?' I know this might sound like textbook stuff without practical use but it's simply the truth, as I learned through the years. In those years my functions only became shorter, and hence better named, and more reusable, and all code simpler to read. So auto was a godsend that didn't hurt once.
foo(A * x) doesn't pose similar problem. On the other hand, if I write
Then we can have the same problem (esp. if foo is a templated function).