LWN.net Logo

Not everything is a nail...

Not everything is a nail...

Posted Jan 26, 2011 19:52 UTC (Wed) by daglwn (subscriber, #65432)
In reply to: Not everything is a nail... by paulj
Parent article: Sobotka: Why GIMP is inadequate

Implicit destruction (finalization, uninit or whatever you want to call it) seems to me integrally tied to the concept of RAII. Without it, one ends up having to cover all exit points of a scope with explicit calls to cleanup code. Either this means there are several such calls scattered around parts of the enclosing scope or there's a big ugly goto to a common piece of cleanup code. Neither is particularly attractive or maintainable.

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."


(Log in to post comments)

Copyright © 2013, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds