Mon, 10 Apr 2000 10:50:35 +0200, George Russell <[EMAIL PROTECTED]> pisze:
> Would it be possible to implement an operation to lock an MVar
> without any extra expense? So that the thread owning the MVar can
> do things to it, but no other thread can.
What does "lock" mean? takeMVar is a kind of lock itself. And if you
want a separate unlocked/locked state in addition to full/empty, then
why stop here and don't have a higher level lock that would allow to
safely manipulate the lower level lock state, etc. ad infinitum?
MVars should be simple. They are building blocks for more complex
things. Your proposal is roughly equivalent to having MVar (MVar a).
But tryTakeMVar's semantics fits in the curent MVars, it's useful,
looks easy to implement without modifying anything else, and require
more complex types like MVar (Either [MVar ()] a) to be correctly
simulated with what we have now. We seek for a compromise between
simplicity and convenience.
--
__("< Marcin Kowalczyk * [EMAIL PROTECTED] http://qrczak.ids.net.pl/
\__/ GCS/M d- s+:-- a23 C+++$ UL++>++++$ P+++ L++>++++$ E-
^^ W++ N+++ o? K? w(---) O? M- V? PS-- PE++ Y? PGP+ t
QRCZAK 5? X- R tv-- b+>++ DI D- G+ e>++++ h! r--%>++ y-