cvs commit: hugs98/lib Prelude.hs hugs98/lib/exts Exception.hs ConcBase.hs

reid 2001/04/01 21:51:23 PDT Modified files: lib Prelude.hs lib/exts ConcBase.hs Added files: lib/exts Exception.hs Log: Even if the previous commits are bad, things should still work because I haven't changed anything in the normal evaluation path. This set of commits had better work though! Prelude.hs: There's now two kinds of exception: IOError and HugsException. IOErrors are propagated using the normal continuation passing mechanisms - exception handlers are chained together on the heap. (This stuff is unchanged. Changing that would require changes to greencard and every IO primop in Hugs.) HugsExceptions are propagated using longjmp, etc. Exception handlers are piled up on the stack. But, what happens when we have to do a context switch (e.g., a call to Concurrency.yield or Concurrency.takeMVar)? We have to remember all the HugsException catches so that we can restore them when we switch back to that thread. This is what Hugs_Catch is for - it remembers which exception handlers we have to reinstall on the stack when we switch back to the thread. (btw, The type names, constructors, etc. associated with IOResult, etc. really ought to be renamed so they have the word "Hugs" or "prim" in them for the usual namespace-contamination reasons.) ConcBase.hs: Some minor organisation and layout changes - trying to restore a consistent style. Also, forkIO has to make sure that every thread contains both an IOError handler and HugsException handler. new file exts/Exceptions.hs: A (very) cut-down implementation of GHC's Exception module. One big difference is that, because IOError handling is handled separately from HugsExceptions, we can't readily implement throw :: Exception -> a But we can provide throwIO :: Exception -> IO a (which I'll try to persuade the GHC people to ask to their implementation). The other big difference is that GHC's Exception datatype has many constructors for different kinds of errors. Implementing this would require extensive changes to any primops which can raise exceptions - lots of changes. So, instead, you get a HugsException and you can convert it to a string and, if you see fit, try to parse the string. I didn't add GHC's assertions - so they're left out. Adding Dynamic exceptions looked tricky and didn't seem like a pressing need so I left them out. Revision Changes Path 1.7 +32 -1 hugs98/lib/Prelude.hs 1.3 +14 -9 hugs98/lib/exts/ConcBase.hs
participants (1)
-
Alastair Reid