auto storage class - infer or RAII?

Chris Miller chris at dprogramming.com
Sat Nov 11 21:37:43 PST 2006


On Sat, 11 Nov 2006 14:22:19 -0500, Chris Miller <chris at dprogramming.com>  
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.

Actually, could probably also reuse "typeof" for auto type deduction:

    typeof x = new X;



More information about the Digitalmars-d mailing list