3 ms·
It's not 1993. IDEs tell you the type if you hover over the auto. Or control and click takes you to the type definition. You have to weigh up the cost of going
by nly 2y ago
It's not 1993. IDEs tell you the type if you hover over the auto. Or control and click takes you to the type definition.
You have to weigh up the cost of going through the code and changing all the type declarations
auto x = foo();
If you change the return type of foo here you don't have to change 300 call sites. Personally i'd rather change it in one place than 300.
- AlotOfReading 2y agoEditor type deduction is surprisingly unreliable sometimes.
- ninkendo 2y agoWhat about code reviewers? Show me a code review system that lets you hover over the value to see the type… none of the ones I’ve used can do it. For that matter anyone reading the code from a web browser in any other context.
- dgfitz 2y agoFwiw, I agree. I also pull down the branch under review in parallel to the web code review. You’d (probably) not be surprised by the number of times I’ve done this and the code doesn’t even build.
- ranger_danger 2y agoI wonder if most of the reason people use auto is just to save time when typing... if the IDE could auto-resolve the type in the source code when they use auto... would that be a better compromise?
- ogoffart 2y agoEven without auto you have the problem. return foo().bar(); No `auto` and you still don't know the return type of foo. And knowing the type might not be the only reason you'd want an IDE anyway. What is `foo()` doing? I want to be able to easily jump to the definition of that function to verify that the assumption taken by the calling function are correct.
- sour-taste 2y agoThis was probably rhetorical but metas code review tool runs LSP and gives you clickable types where clicking takes you to the definition.