auto storage class - infer or RAII?

Chris Nicholson-Sauls ibisbasenji at gmail.com
Sat Nov 11 11:47:08 PST 2006


Lars Ivar Igesund 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.
> 
> 
> 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 ).
> 

I've already said it before, but it bears repeating yet again.  I also prefer 'scope' for 
this.  Although 'infer' wouldn't be bad -- but please, please, please, not 'var'!  It 
smells too much like a scripting language construct, and besides, my Bovis code is 
overflowing with actual variables named var.  (Probably because of the BVar struct that it 
passes most values around as.  Go figure.)

-- Chris Nicholson-Sauls



More information about the Digitalmars-d mailing list