finalisation

Andreas Raab andreas.raab at gmx.de
Fri Jan 23 11:03:01 UTC 2004


Hi Craig,

> > ...the chance of the process being terminated inbetween the
> > assignment and entering the ensured block is - compared to the
> > probability of being terminated somewhere inside #fileNamed: - so
> > remote it isn't even worth mentioning.
>
> I've experienced it. Apparently you're more of a gambler than I am.

I may well be that you've experienced it, but you can't beat the mathematics
of the situation. If your resource management code relies on having the file
(or socket) creation inside the ensured block, you're in a bad shape. It's
simple enough to show that statistically, chances are (by orders of
magnitude) larger that your code will terminate before the assignment rather
than inbetween the assignment and entering the ensured block. And that was
my point - because of the mathematics involved this kind of failure is for
application resource management pretty much irrelevant. If it does occur it
has to be dealt with by different means (such as finalization) but if you
cannot really handle the failure (and you agreed that it wouldn't prevent a
dangling resource pointers) what's gained by putting the creation inside the
ensured block except from having to add explicit guards for the cleanup
code?! ;-)

Cheers,
  - Andreas




More information about the Squeak-dev mailing list