Imperative Object Destruction

Marcin 'Qrczak' Kowalczyk mk167280@students.mimuw.edu.pl
Mon, 13 Nov 2000 12:28:54 +0100 (CET)


On Mon, 13 Nov 2000, Ashley Yakeley wrote:

> Well, it doesn't solve the problem I'm interested in. The file-handling 
> is just an example, I'd like to solve it for any kind of object 
> destruction, so that this kind of error is always caught at compile-time.

I don't think it's possible without limiting convenience / usefulness.
When an arbitrary IO action may be executed to deal with the object, it
can put it into a mutable reference and then used anywhere, or passed
to another thread, and you've lost control over it.

It can be done in a way similar to the ST monad of GHC and Hugs: tagging
objects and actions with type variables and using a special type for
running the computation which ensures that reference don't escape the
computation (and if they are accessed from elsewhere then they are not
usable there anyway). It restricts doable actions to those provided by the
ST monad - no mixing with arbitrary IO.

-- 
Marcin 'Qrczak' Kowalczyk