I don't like auto. (the auto-typing I mean)
Oskar Linde
olREM at OVEnada.kth.se
Sat Mar 11 00:13:59 PST 2006
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
More information about the Digitalmars-d
mailing list