[gclist] Finalization and death notices
Mon, 08 Oct 2001 09:03:34 -0500
At 04:33 PM 10/7/01 -0600, you wrote:
>One way out is to give up on "general", and perhaps "ordered" and
>impose restrictions on finalizers to ensure safety. As I noted,
>it is already the case that throwing an exception from a C++
>destructor is unsafe, so there is precedent there for restricting
>cleanup operations. It wouldn't bother me if optaining locks in
>cleanup functions were also unsafe. Different restrictions might
>be appropriate in other languages, but the idea that the only thing
>a cleanup function should do is release resources seems appropriate
Throwing exceptions is unavoidable. People are imperfect and write
imperfect code, imperfect code often throws exceptions. Any language design
of anything that says you "Code here but no exceptions here." is nonsense.
You can't safely throw exceptions in a destructor so C++ destructiors are
nonsense. I never realized this before.
Death notices can be sent very early for some objects and the processing of
death notices is simply normal code. This is simply cleaner design.