
Svein Ove Aas wrote:
Okay. I've tested, and there is no bug.
This breaks my mental model of how unsafePerformIO actually works somewhat. I'm going to have to chat with #ghc before I can write any comments.
thanks for the written reflections! (and someday when we're sufficiently confident that they're correct, it can turn into comments in the code :-) So, how it works, as I understand it: when GHC resumes the thread, it does not re-execute the throwTo (since it was already executed last time), just like it would not re-execute a putChar. The only reason we don't use throw/throwIO is that a closure interrupted by a *synchronous* exception won't be re-tried at all by the RTS (it will memorize that it evaluates to that exception, instead -- after all, that's more efficient in normal, pure, non-unsafePerformIO cases where a thunk leads to an error-call). now, I might have misunderstood, or it might have changed (there was a discussion a few months(?) ago, about what to do in general about throw/throwTo/unsafePerformIO; -- and this is all fiddly business) -Isaac