Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C++ (http://www.velocityreviews.com/forums/f39-c.html)
-   -   Re: Why is RAII called RAII? (http://www.velocityreviews.com/forums/t733121-re-why-is-raii-called-raii.html)

Johannes Schaub (litb) 09-12-2010 08:17 PM

Re: Why is RAII called RAII?
 
Rolf Magnus wrote:

> Hi,
>
> RAII stands for "resource acquistion is initialization", but it seems
> unlogicyl to me since the concept is not at all about acquiring resources,
> but rather about releasing them as part of the deinitialization
> (destructor). In fact, in many cases, the resources at not acquired at
> initialization time but later on during object lifetime. So why is it
> called RAII after all?


In fact, some folks on irc.freenode.org ##c++ call it "SBRM", like "scope
bound resource management".

Juha Nieminen 09-17-2010 12:41 PM

Re: Why is RAII called RAII?
 
"Johannes Schaub (litb)" <schaub-johannes@web.de> wrote:
> Rolf Magnus wrote:
>
>> Hi,
>>
>> RAII stands for "resource acquistion is initialization", but it seems
>> unlogicyl to me since the concept is not at all about acquiring resources,
>> but rather about releasing them as part of the deinitialization
>> (destructor). In fact, in many cases, the resources at not acquired at
>> initialization time but later on during object lifetime. So why is it
>> called RAII after all?

>
> In fact, some folks on irc.freenode.org ##c++ call it "SBRM", like "scope
> bound resource management".


It seems to me that there are two completely distinct notions being
defined by "RAII":

1) Initialization (and destruction) of acquired resources.
2) Automatic lifetime of objects based on scope.

"RAII" would define the first, while "SBRM" you mention would define the
second.

James Kanze 09-18-2010 09:18 AM

Re: Why is RAII called RAII?
 
On Sep 17, 1:41 pm, Juha Nieminen <nos...@thanks.invalid> wrote:
> "Johannes Schaub (litb)" <schaub-johan...@web.de> wrote:


[...]
> It seems to me that there are two completely distinct notions
> being defined by "RAII":


> 1) Initialization (and destruction) of acquired resources.
> 2) Automatic lifetime of objects based on scope.


> "RAII" would define the first, while "SBRM" you mention would
> define the second.


In many ways, that would be logical. But we're dealing with
human language here, so logic doesn't have much to do with it.
The generally accepted meaning of RAII is the use of destructors
to free resources, despite the origins of the accronym.

For that matter, it's offen used for things like reference
counted pointers, where it's more a case of the destructor
might (or might not) free the resource.

--
James Kanze




All times are GMT. The time now is 09:52 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.