auto

janderson askme at me.com
Thu Jun 21 23:04:00 PDT 2007


janderson wrote:
> Hoenir wrote:
>> I still can't get the purpose of "auto".
>> I know it makes it possible to e.g. write "auto y = 4u;" but why not 
>> just "uint y = 4;"?
> 
> Its a generic/maintainable way of programming.  It means you can change 
> the types your using without having to change ever reference to it.  It 
> means you can copy paste or template a piece of code and have it work 
> with little change.
> 
> It gets even more useful in larger programs when you start to layer this 
> sort of general programming.
> 
> I hope that helps.

I should add, in the same vain (as others have mentioned in other ways), 
its useful for creating code that will work even when someone changes 
the interface.

-Joel


More information about the Digitalmars-d-learn mailing list