On Monday, 30 April 2018 at 21:11:07 UTC, Gerald wrote:
I'll freely admit I haven't put a ton of thought into this post
(never a good start), however I'm genuinely curious what
people's feeling are with regards to the auto keyword.
Speaking for myself, I dislike the auto keyword. Some of this
is because I have a preference for static languages and I find
auto adds ambiguity with little benefit. Additionally, I find
it annoying that the phobos documentation relies heavily on
auto obscuring return types and making it a bit more difficult
to follow what is happening which gives me a bad taste for it.
Having said, the thing that really started my thinking about
this was this post I made:
https://forum.dlang.org/thread/fytefnejxqdgotjkp...@forum.dlang.org
Where in order to declare a public variable for the
RedBlackTree lowerBound/upperBound methods I had to fall back
on using the ReturnType template to declare a variable.
Jonathan was nice enough to point me in the right direction and
maybe there's a way to do this without having to fall back on
ReturnType. However this made be wonder if reliance on auto
could discourage API writers from having sane return types.
So I'm curious, what's the consensus on auto?
Auto is useful... simple as that. If you don't like it don't use
it. If you get confused about it then beef up your game in
analysis. Obscurity can be done many ways so complaining about
one specific way is not very thought out.
myfunkytypethatyoudontknowabouthiddenthrough100layersofabstraction foo();