Remove declaration 'auto' for RAII?
Chris Miller
chris at dprogramming.com
Tue Mar 14 17:13:24 PST 2006
On Mon, 13 Mar 2006 10:02:49 -0500, Tom <Tom_member at pathlink.com> wrote:
> 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.
They accomplish the same thing, but perhaps scope can be used to indicate
RAII:
scope(raii) Foo f = new Foo;
or scope(auto)
etc
More information about the Digitalmars-d
mailing list