[Python-Dev] Finalization in Eiffel

Tim Peters tim_one@email.msn.com
Fri, 10 Mar 2000 21:03:47 -0500

Eiffel is Bertrand Meyer's "design by contract" OO language.  Meyer took
extreme care in its design, and has written extensively and articulately
about the design -- agree with him or not, he's always worth reading!

I used Eiffel briefly a few years ago, just out of curiosity.  I didn't
recall even bumping into a notion of destructors.  Turns out it does have
them, but they're appallingly (whether relative to Eiffel's usual clarity,
or even relative to C++'s usual lack thereof <0.9 wink>) ill-specified.

An Eiffel class can register a destructor by inheriting from the system
MEMORY class and overriding the latter's "dispose()".  This appears to be
viewed as a low-level facility, and neither OOSC (2nd ed) nor "Eiffel: The
Language" say much about its semantics.  Within dispose, you're explicitly
discouraged from invoking methods on *any* other object, and resurrection is
right out the window.  But the language doesn't appear to check for any of
that, which is extremely un-Eiffel-like.  Many msgs on comp.lang.eiffel from
people who should know suggest that all but one Eiffel implementation pay no
attention at all to reachability during gc, and that none support
resurrection.  If you need ordering during finalization, the advice is to
write that part in C/C++.  Violations of the vague rules appear to lead to
random system damage(!).

Looking at various Eiffel pkgs on the web, the sole use of dispose was in
one-line bodies that released external resources (like memory & db
connections) via calling an external C/C++ function.

jealous-&-appalled-at-the-same-time<wink>-ly y'rs  - tim