Not logged in
Log in now
Create an account
Subscribe to LWN
An unexpected perf feature
LWN.net Weekly Edition for May 16, 2013
A look at the PyPy 2.0 release
PostgreSQL 9.3 beta: Federated databases and more
LWN.net Weekly Edition for May 9, 2013
Not everything is a nail...
Posted Jan 25, 2011 16:06 UTC (Tue) by jrn (subscriber, #64214)
Posted Jan 25, 2011 16:41 UTC (Tue) by etienne (subscriber, #25256)
Posted Jan 25, 2011 22:18 UTC (Tue) by daglwn (subscriber, #65432)
RAII is about MUCH more than memory.
Posted Jan 26, 2011 12:32 UTC (Wed) by paulj (subscriber, #341)
C++ has implicit calls to constructors and destructors, which tie in to scoping. C doesn't have that, true, and requires explicit construction and destruction (you can still hide destruction behind refcounting, obv). It's often bad practice and/or a sign of a (quick)? hack when C code uses automatic allocating for non-trivial, composite objects.
Whether language support for implicit ctor/dtors tied with scoping is required for a practice to be called RAII, I don't know. I guess to a C++ person it does. Still, the general sentiment of RAII seems more widely applicable than C++.
Posted Jan 26, 2011 19:52 UTC (Wed) by daglwn (subscriber, #65432)
This gets to be impossible if the exit points are not known statically. C++ exceptions are a classic example but since some seem to think the C++ exception model is broken, I will emphasize that the problem is NOT solved by eliminating exceptions. One still has to cover all exit points with cleanup code.
Perhaps a better term for this would have been "resource ownership is object lifetime."
Copyright © 2013, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds