[M3devel] an old, recurring issue: mapping runtime errors to exceptions?

Mika Nystrom mika at async.caltech.edu
Tue Apr 21 23:41:49 CEST 2009


Hello Modula-3ers,

I know this is a question that comes up from time to time, and I
am aware of Greg Nelson's short article in "Threads" about why 
Modula-3 doesn't map runtime errors to exceptions, but the Green Book
does allude to mapping runtime errors to exceptions, and I know that
the SPIN OS did that.

How hard would this be to support in CM3?

Attached is a transcript of an interactive session with my current
Scheme environment.  I think it ought to be obvious why I ask about
exceptions.  In Modula-3, from safe code, only checked runtime errors
can occur.  Checked runtime errors cannot violate invariants of the
runtime system, so it ought to be safe to convert them to exceptions
that can be caught, and then permit the program to continue.  

I realize this isn't *always* what you want to do, but in an interactive
environment, making the system dump core on runtime errors sort of
spoils the whole experience.

In this application, there are many places where you may want to
raise an exception that hasn't been declared.  In a non-interactive
environment, it is probably best to go for the core dump, but in
an interactive environment, it seems to me it ought to just return
control to the read-eval-print loop....

     Mika

LITHP ITH LITHENING.
> (define wr (scheme-procedure-stubs-call '(TextWr . New) '()))
wr
> wr
<Modula-3 object : TextWr.T, BRANDED TextWr_^%#%^__0001M>
> (scheme-procedure-stubs-call '(Wr . PutText) (list wr "hello!") '())
#t
> (scheme-procedure-stubs-call '(TextWr . ToText) (list wr) '())
"hello!"
> (scheme-procedure-stubs-call '(TextWr . ToText) (list wr) '())
""
> (scheme-procedure-stubs-call '(Wr . PutText) (list wr "hello!") '())
#t
> (scheme-procedure-stubs-call '(Wr . PutText) (list wr "hello!") '())
#t
> (scheme-procedure-stubs-call '(Wr . PutText) (list wr "hello!") '())
#t
> (scheme-procedure-stubs-call '(Wr . PutText) (list wr "hello!") '())
#t
> (scheme-procedure-stubs-call '(Wr . PutText) (list wr "hello!") '())
#t
> (scheme-procedure-stubs-call '(TextWr . ToText) (list wr) '())
"hello!hello!hello!hello!hello!"
> (scheme-procedure-stubs-call '(TextWr . ToText) (list '()) '())


***
*** runtime error:
***    Segmentation violation - possible attempt to dereference NIL
***    pc = 0x80c69c8 = LockMutex + 0x28 in /usr/ports/lang/ezm3/work/ezm3-1.0/libs/m3core/src/thread/POSIX/ThreadPosix.m3
***

  use option @M3stackdump to get a stack trace
Abort


 





More information about the M3devel mailing list