3 ms·
Are you sad because of the auto, or the terrible variable names? auto gps_position = *saved_position; I can think of cases where I'd want to see the type of
by RogerL 12y ago
Are you sad because of the auto, or the terrible variable names?
auto gps_position = *saved_position;
I can think of cases where I'd want to see the type of auto, but not often.
- SamReidHughes 12y agoThere are a ton of times in C++ or any language where you want the type. If having the type makes the code more readable, you should have it.
- RogerL 12y agoThis is what everyone is saying. The only question is whether to ever use auto in non-generic code. I think it is unarguable that if you can write foo(goo()) in a clean way you can equally use auto. And if you can't do the former, you probably can't do the latter. Balance, proportion, judgment, and code reviews are how you get great code, not 'never' and 'always' rules (which your comment makes clear you agree with).
- AlisdairO 12y agoOne of the nice things about explicit types is that you can make sense of the code even when the person who wrote it wasn't the best at variable naming. I tend to distrust relying on convention. That said, presumably one solution for such an issue is that have IDEs that can easily tell you what the type of an auto variable is.