What should have been the term for RAII?
Bjarne Stroustrup himself said he was very busy when he came up with the name for this concept, that it’s not a very good name, and joked he’s not good at “marketing“.
What would be a better terminology?
As I’ve been learning modern C++, I admit that I’ve struggled to understand why these terms make sense. To me, I think of it like “Resource Acquisition Promising Release”. Does this betray that I am not truly understanding Strourstrup’s principle?
I’m a Rust programmer but I would call it scope-based or scope-bound resource management, a popular alternative term in the C++ community.
Can we use some wilderness phrases like “Pack It In, Pack It Out” or “Leave No Trace”?
DRR, destructor resource release. At least that's the relevant part to me...
”For dust thou art, and unto dust thou shall return”
Constructor Acquires, Destructor Releases.
The most important part for me is not construction,but the guaranteed destruction. So what about:
Resource Is Getting Guaranteed to End up Destructed.
I try to have RIGGED as backronym, but the words are not completely right. Even so, the slogan could work like this: Prefer using RIGGED resources in C++
BTW, a lot of people in this thread compare destructors to Java's try-with-resource (similarly, C#'s using), or Go's defer.
Here's one important difference: Destructors work in standard data structures. If for whatever reason you want to build a map>, and the map goes out of scope, all files are correctly closed. (Rust's drop semantics work the same way.) That's a lot more work in Java or C#.
Something with scopes? "Scoped resources" ?
Wow, such good ideas here. I guess no one is keen on my "RAPR" proposal :)
But just to reflect a bit more, I think my curiosity/confusion stems from the "is initialization" wording, and how the word "initialization" in the context of C++ will imply a guaranteed freeing step?
I've tried reconciling how its defined here:
https://en.cppreference.com/w/cpp/language/initialization
However, it seems like wording describing ideas around how a resource is created, and not how it's completed.
cppreference defines it as:
> Resource Acquisition Is Initialization or RAII, is a C++ programming technique[1][2] which binds the life cycle of a resource that must be acquired before use (allocated heap memory, thread of execution, open socket, open file, locked mutex, disk space, database connection—anything that exists in limited supply) to the lifetime of an object.
I’d crib the name from Rust, this is ownership, where the object owns the resource.
After not much thought on the matter, I'd call it Resourceful Instantiation.
I think scope or similar is good.
Also, see related video here
CppCon 2015: Andrei Alexandrescu “Declarative Control Flow"
https://youtu.be/WjTrfoiB0MQ?t=1046
I would just call it "destructors". It's a little imprecise because some GC languages also have destructors, but arguably they shouldn't.
I also know it as 'janitor', but maybe thats not a known term or something different?
I tend to use "deterministic finalizers" for the part that (in my understanding) is the most critical
I always just referred to it as "deterministic destruction." I think that's reasonable, anyway.
Managed resource lifetime
it sounds like Disposable