Eiffel "Gotchas"

07 April 1998


Gotcha #11 - cleaning up

Suppose you want to make sure that a routine 'clean_up' is executed immediately before your application exits. Is it sufficient to make sure that a call to 'clean_up' is the last instruction of the creation feature of your root class?

   class MAIN
   creation make
   feature
      make is
         do
            ...
            clean_up
         end
   end

No, because the application may exit due to an unhandled exception. So maybe this is enough:

   class MAIN
   creation make
   feature
      make is
         do
            ...
            clean_up
         rescue
            ...
            clean_up
         end
   end

In this case, even an un-retried exception will result in a call to 'clean_up' before execution leaves the rescue clause and the exception propagates to the run-time default exception handler.

But it turns out this is not enough - what's the problem?

ANSWER


Eiffel and NICE are registered trademarks of the Nonprofit International Consortium for Eiffel.

Eiffel "Gotchas"