Add := digraph to D
Christophe Travert
travert at phare.normalesup.org
Thu Jun 21 01:04:35 PDT 2012
"Lars T. Kyllingstad" , dans le message (digitalmars.D:170370), a
>>> auto name = initializer;
>>> const name = initializer;
>>> immutable name = initializer;
>>> shared name = initializer;
>>> enum name = initializer;
>>
>> After the first aren't these all just short hand for "const
>> auto name = init" etc with the given keyword?
>
> No. Many don't realise this, but "auto" doesn't actually stand
> for "automatic type inference". It is a storage class, like
> static, extern, etc., and it means that the variable stops
> existing at the end of the scope. It is, however, the default
> storage class, which is why it is useful when all you want is
> type inference. Even C has auto.
auto is called a storage class, but where did you read that auto would
make the variable stop existing at the end of the scope ?
int delegate(int) add(int i, int j)
{
auto k = i+j;
return a => a+k;
}
Are you sure k will stop existing at the end of the scope ? I have no
compiler at hand to check this, but I would be very surprised.
Object Create()
{
auto k = new Object();
return k;
}
Same question.
--
Christophe
More information about the Digitalmars-d
mailing list