Content deleted Content added
m Task 18 (cosmetic): eval 17 templates: del empty params (2×); hyphenate params (1×); |
another reference |
||
Line 8:
| accessdate=2019-03-09}}</ref> is a [[programming idiom]]<ref>{{cite book |last1=Sutter |first1=Herb |author-link1=Herb Sutter |last2=Alexandrescu |first2=Andrei |author-link2=Andrei Alexandrescu |year=2005 |title=C++ Coding Standards |url=https://archive.org/details/isbn_0321113586 |url-access=limited |series=C++ In-Depth Series |publisher=Addison-Wesley |page=[https://archive.org/details/isbn_0321113586/page/n54 24] |isbn=978-0-321-11358-0 }}</ref> used in several [[Object-oriented programming|object-oriented]], [[Statically-typed programming language|statically-typed]] programming languages to describe a particular language behavior. In RAII, holding a resource is a [[class invariant]], and is tied to [[object lifetime]]: [[Resource allocation (computer)|resource allocation]] (or acquisition) is done during object creation (specifically initialization), by the [[Constructor (object-oriented programming)|constructor]], while resource deallocation (release) is done during object destruction (specifically finalization), by the [[Destructor (computer programming)|destructor]]. In other words, resource acquisition must succeed for initialization to succeed. Thus the resource is guaranteed to be held between when initialization finishes and finalization starts (holding the resources is a class invariant), and to be held only when the object is alive. Thus if there are no object leaks, there are no [[resource leak]]s.
RAII is associated most prominently with [[C++]] where it originated, but also [[D (programming language)|D]], [[Ada (programming language)|Ada]],{{citation needed}} [[Vala (programming language)|Vala]],<ref>{{
| url=https://stackoverflow.com/a/99986
| title=How do you pronounce RAII?
|