Explicit keyword for "plain old local variable" storage class?
Norbert Nemec
Norbert at Nemec-online.de
Sat May 27 02:37:10 PDT 2006
BCS wrote:
> Hasan Aljudy wrote:
>> Charlie wrote:
>>
>>> 2) auto auto foo = new Class; The current double meaning of auto
>>> won't allow for both a RAII and type-deduced variable declaration.
>>> I think every other language use's 'var' or similar ( var gets my
>>> vote, used in php, javascript, C#-3.0) . The current error is
>>> 'redundant storage class 'auto''.
>>
>>
>> auto can mean many many things!!
>>
>> I prefer to get rid of auto all together.
>> for automatic type inference ==> use 'var'
>> for RAII, hmm, maybe use something like 'raii'
>>
>> # raii var foo = new Foo;
>>
>>
> IIRC that would be:
>
> #raii foo = new Foo;
>
> the "auto" dosn't indicate auto typing, it's just a storage classe to
> indecate a decleration. "auto" is used because most of the time it has
> no effect.
Maybe that common confusion could be lifted by introducing a new storage
class (e.g. "local" or "var") indicating a "plain old local variable".
This would be the default for any variable declared with a type and
without storage class, but it would be useful in declaring a
type-induced variable that is not intended to be an auto variable.
>
> These all works:
>
> void main()
> {
> auto f2 = cast(int)'\n';
> const f3 = cast(int)'\n';
> extern f5 = cast(int)'\n';
> static f8 = cast(int)'\n';
> synchronized f9 = cast(int)'\n';
> }
>
> see http://www.digitalmars.com/d/declaration.html#AutoDeclaration
More information about the Digitalmars-d
mailing list