Finalizers strike back

Malcolm Wallace Malcolm.Wallace at
Fri Oct 11 11:25:18 EDT 2002

George Russell <ger at> writes:

> it would normally be a good idea for implementations and programmers to
> provide and use MVars, even if they do not provide and use concurrency,
> ...   If NHC does not provide MVars, I think it should.

I don't think MVars make any sense without concurrency, so I don't see
the point of implementing the one without the other.  I'm willing to
be persuaded otherwise.  (It would be nice to have some concurrency
in nhc98, of course, but I don't foresee that happening soon.)

> I apologise to Malcolm, but in any case I doubt if implementing
> MVars in a world with only one thread would cost him a great deal of
> effort.

Well it would be simple enough provided you didn't mind your
computation halting with deadlock rather unpredictably.  :-)

Actually, I'm just wondering whether I can use the GC as a poor-man's
scheduler.  If a finaliser blocks on an MVar, save its state, keep
the finaliser in the pending queue, and return to the main thread.
Then on the next GC, try the same finaliser again, ad infinitum until
it succeeds.


More information about the FFI mailing list