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. Advertisements

  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. Advertisements

  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. Advertisements

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:
    781
    velthuijsen
    Apr 16, 2004
  2. Mr. SweatyFinger

    why why why why why

    Mr. SweatyFinger, Nov 28, 2006, in forum: ASP .Net
    Replies:
    4
    Views:
    1,369
    Mark Rae
    Dec 21, 2006
  3. Mr. SweatyFinger
    Replies:
    2
    Views:
    2,837
    Smokey Grindel
    Dec 2, 2006
  4. Weng Tianxiang
    Replies:
    6
    Views:
    803
    glen herrmannsfeldt
    Sep 12, 2007
  5. S_K
    Replies:
    6
    Views:
    1,544
    Robert Dunlop
    Nov 8, 2007
  6. Jimmy Hartzell
    Replies:
    0
    Views:
    630
    Jimmy Hartzell
    May 19, 2008
  7. cpp4ever

    Re: Why is RAII called RAII?

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

    Re: Why is RAII called RAII?

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