auto: useful, annoying or bad practice?
Charles Hixson
charleshixsn at earthlink.net
Sun May 20 23:01:39 UTC 2018
auto has its uses, but it's wildly overused, especially in library code
and documentation, and really, really, *really* much so in documentation
examples.
On 05/01/2018 06:09 AM, Craig Dillabaugh via Digitalmars-d wrote:
> 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.
>>
> clip
>>
>> So I'm curious, what's the consensus on auto?
>
> As some have pointed out, it certainly has value. For example, in
> functions returning ranges, etc. where you wouldn't want to have to
> write out the whole type.
>
> However, as an infrequent D user I admit I prefer to see the actual
> type where it is feasible, as I find 'auto' is a barrier to
> understanding to someone who isn't familiar with a particular piece of
> code. I would never use auto in place of a basic type.
>
>
More information about the Digitalmars-d
mailing list