Unpopular opinion: C++ `auto` should be almost always avoided. The only thing it gives is code that is harder to read, maintain and debug.
-
-
Vastauksena käyttäjälle @savage309
Not trying to gatekeep, but I think that opinion is only unpopular if you haven't used auto much.
2 vastausta 0 uudelleentwiittausta 6 tykkäystä -
Vastauksena käyttäjille @eddieparker ja @savage309
I’ll bite: for stack vars of boring or long types, it’s very convenient. On the off chance you do refactoring like replacing a class-returning function with an interface-returning function, the lack of changes required in callers due to auto usage feels magic. They’re quite nice.
1 vastaus 0 uudelleentwiittausta 6 tykkäystä -
Vastauksena käyttäjille @walkerb ja @savage309
Yeah, that was my first opinion too. But then when you try to debug it months later and struggle to quickly remember the under lying type; you regret it. It makes for faster code writing, not reading, imo, which isn't the critical part of dev
2 vastausta 0 uudelleentwiittausta 6 tykkäystä -
Vastauksena käyttäjille @eddieparker ja @savage309
Strong agree that reading is more critical than writing. I guess I’ve just used auto for years and never hit a big due to misinterpreting the type of an “auto”. I also don’t put braces around one-line if statements (never hit a bug about that!), so maybe I just live dangerously.
1 vastaus 0 uudelleentwiittausta 6 tykkäystä -
Vastauksena käyttäjille @walkerb ja @savage309
They interesting thing I find is that I have the opposite opinion of 'var' in c#. I find it makes code much more readable and easier to type. It helps that IDEs for c# are more robust than c++ I imagine.
1 vastaus 0 uudelleentwiittausta 1 tykkäys -
Vastauksena käyttäjille @eddieparker ja @savage309
Oh, this is an interesting modifier. Although I've used auto professionally, I've been full-time writing c# for the past year and am definitely transferring my feelings about using c# "var" to c++ "auto". I'd agree hovering "auto" and Intellisensing its type is a big factor.
1 vastaus 0 uudelleentwiittausta 3 tykkäystä -
I’s say plenty of time spent with code is spent outside of an IDE though
1 vastaus 0 uudelleentwiittausta 3 tykkäystä -
+1 also, I do all of my MAME coding with nothing but TextPad and invoking builds from the command-line
Lataaminen näyttää kestävän hetken.
Twitter saattaa olla ruuhkautunut tai ongelma on muuten hetkellinen. Yritä uudelleen tai käy Twitterin tilasivulla saadaksesi lisätietoja.