Re: Why is RAII called RAII?

Discussion in 'C++' started by Johannes Schaub (litb), Sep 12, 2010.

  1. 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".
     
    Johannes Schaub (litb), Sep 12, 2010
    #1
    1. Advertising

  2. "Johannes Schaub (litb)" <> 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.
     
    Juha Nieminen, Sep 17, 2010
    #2
    1. Advertising

  3. Johannes Schaub (litb)

    James Kanze Guest

    On Sep 17, 1:41 pm, Juha Nieminen <> wrote:
    > "Johannes Schaub (litb)" <> 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
     
    James Kanze, Sep 18, 2010
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Apricot
    Replies:
    4
    Views:
    560
    velthuijsen
    Apr 16, 2004
  2. Mr. SweatyFinger
    Replies:
    2
    Views:
    2,228
    Smokey Grindel
    Dec 2, 2006
  3. S_K
    Replies:
    6
    Views:
    1,253
    Robert Dunlop
    Nov 8, 2007
  4. cpp4ever

    Re: Why is RAII called RAII?

    cpp4ever, Sep 12, 2010, in forum: C++
    Replies:
    1
    Views:
    429
    BGB / cr88192
    Sep 13, 2010
  5. Goran Pusic

    Re: Why is RAII called RAII?

    Goran Pusic, Sep 13, 2010, in forum: C++
    Replies:
    11
    Views:
    593
    ptyxs
    Sep 16, 2010
Loading...

Share This Page