auto storage class - infer or RAII?

Dave Dave_member at pathlink.com
Sat Nov 11 15:09:12 PST 2006


Kyle Furlong wrote:
> Chris Miller wrote:
>> On Sat, 11 Nov 2006 13:48:00 -0500, Walter Bright 
>> <newshound at digitalmars.com> wrote:
>>
>>> The auto storage class currently is a little fuzzy in meaning, it can 
>>> mean "infer the type" and/or "destruct at end of scope". The latter 
>>> only has meaning for class objects, so let's look at the syntax. 
>>> There are 4 cases:
>>>
>>
>> Choosing from your list I guess "auto" for auto destruction and 
>> "infer" for auto type deduction.
>>
>> However, I tend to prefer "scope" (without parentheses following) for 
>> auto destruction, which frees up "auto" for auto type deduction:
>>
>>    scope Object o = new Object(); // Destructed at end of scope.
>>    scope auto q = new Foo(); // Auto type deduction and end-of-scope 
>> destruction.
> 
> scope has my vote, its elegant, as raii is functionally similar to the 
> scope(x) construct.

Vote++.

But Walter specifically (and I think purposefully) left out any mention of new keywords. Nonetheless 
I'd like to see auto deprecated in favor of 'infer'. 'scope' and 'infer' both describe exactly what 
they are used for. 'auto' just seems too much like a deprecated artifact of C.

Based on previous discussions though, 'auto' is here to stay one way or the other forever. I 
sincerely don't understand Walter's infatuation with 'auto', but it is what it is.



More information about the Digitalmars-d mailing list