auto: useful, annoying or bad practice?
Nerve
nervecenter7 at gmail.com
Thu May 3 09:29:57 UTC 2018
On Monday, 30 April 2018 at 21:11:07 UTC, Gerald wrote:
> So I'm curious, what's the consensus on auto?
Speaking for myself:
1) I find auto to be useful when instantiating objects locally;
eliminates redundancy, noise, and line size.
2) I avoid auto functions and despise them in API documentation.
It’s difficult to work with the return type of a function when
the definition is auto and the author didn’t follow up by
describing exactly what was returned.
3) I avoid auto for primitive types because their type names are
short, and declaring them C- and Ada-style at the beginning of a
local block helps massively clarify what a function is about to
do.
So basically only for object instantiations. I’ve yet to find a
great use for it outside of that.
More information about the Digitalmars-d
mailing list