Earlier quoted context omitted.
Are there languages that do SBRM but not RAII?
Rust doesn’t have initializers in the C++ sense. And I mean, even in C++ many classes like shared_ptr or even lock_guard have constructors that don’t acquire the resources yet. When the resource is acquired is an API design concern; the important part is where it’s released.
Ask HN: What should have been the term for RAII?
11–20 of 62 posts
Re: Ask HN: What should have been the term for RAII?
#12Constructor Acquires, Destructor Releases.
The earliest mention of this idea (CADR / CADRe) I’ve found is from 2012: https://groups.google.com/a/isocpp.org/g/std-proposals/c/Una...
Re: Ask HN: What should have been the term for RAII?
#13Re: Ask HN: What should have been the term for RAII?
#14Earlier quoted context omitted.
Rust doesn’t have initializers in the C++ sense. And I mean, even in C++ many classes like shared_ptr or even lock_guard have constructors that don’t acquire the resources yet. When the resource is acquired is an API design concern; the important part is where it’s released.
This sounds like an argument that C++ isn't RAII.
Re: Ask HN: What should have been the term for RAII?
#15Re: Ask HN: What should have been the term for RAII?
#16Earlier quoted context omitted.
I too was going to say this! The earliest mention of this idea (CADR / CADRe) I’ve found is from 2012: https://groups.google.com/a/isocpp.org/g/std-proposals/c/Una...
Unfortunate acronym, you're going to get a bunch of lisp docs...
Who is that for? Dummies who get it backwards? Oh, look, you're releasing in your destructor and acquiring in the destructor. Did you forget your CADR?
Re: Ask HN: What should have been the term for RAII?
#17> 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.
Re: Ask HN: What should have been the term for RAII?
#18Earlier quoted context omitted.
I too was going to say this! The earliest mention of this idea (CADR / CADRe) I’ve found is from 2012: https://groups.google.com/a/isocpp.org/g/std-proposals/c/Una...
Unfortunate acronym, you're going to get a bunch of lisp docs...
I even had my own proposal 5 years ago for improving that!
> That's right, but I would go one step further and have F(irst) and R(est), with obvious composition as follows: (using kruhft's examples from another thread)
> (ff x) == (caar x) == (car (car x))
> (rrf x) == (cddar x) == (cdr (cdr (car x)))
> I would argue that it's worth sacrificing the 'f' and 'r' symbols for such a common construct.> …
> Yes, I realize I'm 55 years late to the party.
https://news.ycombinator.com/item?id=13259344
Now we only need to implement both changes at the same time! :-P
Re: Ask HN: What should have been the term for RAII?
#19I’m a Rust programmer but I would call it scope-based or scope-bound resource management, a popular alternative term in the C++ community.
RAII isn't just about automatic ("scope-based") variables. RAII refers to the way the language ties together the construction and allocation of the object.
Re: Ask HN: What should have been the term for RAII?
#20Earlier quoted context omitted.
RAII isn't just about automatic ("scope-based") variables. RAII refers to the way the language ties together the construction and allocation of the object.
Are there languages that do SBRM but not RAII?
For C++ and Rust there might not be a well defined scope since objects can be „moved“. Eg a method constructing an object can return it to the caller without the destructor being called.