auto storage class - infer or RAII?

Kyle Furlong kylefurlong at gmail.com
Sat Nov 11 14:46:20 PST 2006


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.



More information about the Digitalmars-d mailing list