I don't like auto. (the auto-typing I mean)

Ameer Armaly ameer_armaly at hotmail.com
Sat Mar 11 04:41:58 PST 2006


"Oskar Linde" <olREM at OVEnada.kth.se> wrote in message 
news:duu0t3$1rqc$1 at digitaldaemon.com...
> 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);
>
> ?
>
Since it's obviously something we don't want, just because it exists doesn't 
mean we should compound the problem by making it even more common.
> /Oskar 





More information about the Digitalmars-d mailing list