DMD 1.035 and 2.019 releases

Extrawurst spam at extrawurst.org
Wed Sep 3 05:17:54 PDT 2008


Mosfet wrote:
> When I look at documentation I can read :
> The auto attribute is used when there are no other attributes and type 
> inference is desired.
> 
> In which case you want inference type ? Is it a kind o C++ RTTI ?
> In the sample code above, you already know that struct is of kind S.
> First I thought auto means automatically destruct object when out of scope.

auto just helps writing code in a more brief and readable way. The 
compiler infers the type which u are using by the right side of the 
expression, which is extremly handy when u use cascaded templates a lot.

example:
MyTemplateA!(MyTemplateB("foo")) variablename = new 
MyTemplateA!(MyTemplateB("foo"))("aParemterString");

with auto u just have to write it once:
auto variablename = new MyTemplateA!(MyTemplateB("foo"))("aParemterString");

the compiler infers the type of variablename looking at the expression.


More information about the Digitalmars-d-announce mailing list