auto storage class - infer or RAII?

Lars Ivar Igesund larsivar at igesund.net
Sat Nov 11 11:27:03 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.

Considering that scope already exists as a keyword, I find this an excellent
suggestion that is also very much clearer in meaning (I find auto to miss
the target for both cases really :P ).

-- 
Lars Ivar Igesund
blog at http://larsivi.net
DSource & #D: larsivi



More information about the Digitalmars-d mailing list