auto storage class - infer or RAII?

Sean Kelly sean at f4.ca
Mon Nov 13 13:10:22 PST 2006


Tomas Lindquist Olsen wrote:
> Sean Kelly wrote:
>> Tomas Lindquist Olsen wrote:
>>> Another argument for using 'auto' for ATI can be making it consistent 
>>> with how it currently works for classes in DMD:
>>>
>>> class A
>>> {
>>>     static
>>>     {
>>>         auto x = 2;
>>>         auto y = 42;
>>>     }
>>>     auto z = 27;
>>> }
>>>
>>> This works. x and y are static!
>>
>> I think this works everywhere, as you're free to chain storage classes 
>> to your heart's delight:
>>
>>     // what is this??
>>     auto const static const static auto x = 5;
>>
>>
>> Sean
> 
> That does not work:
> scopetest.d(29): redundant storage class 'const'
> scopetest.d(29): redundant storage class 'static'
> scopetest.d(29): redundant storage class 'auto'

Oh, so you can just do:

     auto const static x = 5;

Could be worse, I suppose.

Sean



More information about the Digitalmars-d mailing list