auto: useful, annoying or bad practice?
Gerald
gerald.b.nunn at gmail.com
Mon Apr 30 21:11:07 UTC 2018
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/fytefnejxqdgotjkprpo@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?
More information about the Digitalmars-d
mailing list