I don't like auto. (the auto-typing I mean)
Kyle Furlong
kylefurlong at gmail.com
Sat Mar 11 03:08:23 PST 2006
Oskar Linde wrote:
> Jarrett Billingsley wrote:
>
>> More and more I see D code strewn with
>>
>> auto someVariable = someExpression();
>>
>> I don't like this. A bit.
>>
>> Everyone seems to be treating auto like it's the best damn thing to come
>> out
>> in the language in a long time. Now in some cases, it's really obvious
>> what the type is, and sometimes saves a lot of typing:
>>
> [snip]
>> auto fork = someFunction();
>>
>> Oh boy. What type is it now? I have to look up someFunction in the docs,
>> or if there are no docs, in the code itself. What module was someFunction
>> in again? Hmm.... where is it... wasted time.
>
> Both C and C++ are full of unnamed temporaries whose types get inferred
> automatically. Compare the above auto statement to:
>
> someOtherFunction(someFunction());
>
> How do you now know the type of someFunction()?
>
> I'm sure you are not proposing that everyone should write:
>
> someOtherFunction((float)someFunction());
>
> So why is this any different from:
>
> auto fork = someFunction();
> someOtherFunction(fork);
>
> ?
>
> /Oskar
Good point
More information about the Digitalmars-d
mailing list