From: "Yukihiro Matsumoto" <matz / ruby-lang.org>
>
[...]
> First of all, what does RAAI stand for?

I've been interpreting it as (a typo for) RAII, the idiom of
"Resource Acquisition is Initialization" used in C++.

[[For the really curious, here's a thread on Usenet where people
discuss the finer points of what RAII "really means" in C++ in
exquisite, laborious, gory detail :-)
http://groups.google.com/groups?hl=en&threadm=B5291D12.4F4C%25abrahams%40mediaone.net&rnum=1 ]]

My take on it is it's applicability basically stems from C++'s
distinction between objects created "locally" on the stack frame,
which have a definite "out of scope condition" at the point their
semantic 'block' is exited in the code, and objects which are
allocated on the heap, which are only contained in pointers (be
they smart or otherwise.)

That is, it's an extra distinction about objects, or object
allocation, that languages like Ruby or Java don't have. . . 
So C++'ers utilize this guaranteed "out of scope destruction"
of locally allocated objects to implement things like smart
pointers (such as std::auto_ptr<>) which can perform an automatic
delete on the type of (heap allocated) object to which they
point, as the smart pointer itself (a locally allocated stack
frame object) goes out of scope.

So the meaning of RAII to me is essentially "acquire resources
during initialization in such a way that cleanup occurs
automatically" as we leave a particular scope block or an
exception is thrown, etc......

One other point comparing C++ to a GC'd language is that I
personally find only a fraction of the objects I create in a 
GC'd language require special treatment in their cleanup.
That is in C++ you have to ensure the cleanup of _everything_,
where is in GC'd languages one need only ensure deterministic
cleanup of objects holding non-memory resources.  Which in my
experience has only been some fraction of the objects I create.
So the whole thing for me is a kind of trade-off: meticulous
adherance to RAII in C++ _all the time_, vs. attending to cleanup
of only certain resource-containing objects in a GC'd language.

And as Rubiers have mentioned, both blocks and begin/ensure
provide a way of handling such cleanups . . .



Regards,

Bill