Remove declaration 'auto' for RAII?

Tom Tom_member at pathlink.com
Mon Mar 13 07:02:49 PST 2006


In article <dv3u5j$2ot1$1 at digitaldaemon.com>, Jarrett Billingsley says...
>
>"Chris Miller" <chris at dprogramming.com> wrote in message 
>news:op.s6csodzipo9bzi at moe...
>> There is a problem with auto when declaring variables!
>>
>> Not only does it have 2 meanings, but when using it for implicit type 
>> inference, it no longer has the RAII quality. So if you say "auto foo = 1" 
>> is much like "static bar = 1", you are mistaken. The 2nd one doesn't cause 
>> it to be non-static, so why does the 1st make it non-RAII?
>>
>> If auto for implicit type inference stays, I propose removing it for RAII 
>> in declarations. If you want RAII you can simply use scope(exit) delete 
>> baz; after the declaration. 

Sorry, why to do that? I don't want to be forced to free every object manually
with scope(exit)? Then it wouldn't be RAII anymore! Or I don't understand your
point.

>> Also, the "auto class {}" form can still stay 
>> since it is in unrelated code and there is no easy replacement for it.
>
>Sigh.. was it really necessary to start another thread about this? 
>
>

Tom;



More information about the Digitalmars-d mailing list