What is the correct use of auto?

Edward Diener eddielee_no_spam_here at tropicsoft.com
Fri Apr 11 06:13:16 PDT 2008


Hans W. Uhlig wrote:
> I have been reading through the specification and playing with D more 
> and more, what is the purpose of auto. I can understand in languages 
> with scalar types handling datatypes on assignment but on a strictly 
> typed language like C or D when would auto(as a variable declaration) 
> provide more useful functionality then it removes from readability.
> 
> When would this be useful rather then simply specifying the type?

Templates, where the specific type(s) are not known to the template 
writer !

It is the same reason why the next version of C++ will have this 
functionality also.



More information about the Digitalmars-d mailing list