1.42. Dynamic exception handling using goto

Non local gotos are very useful for a form of exception handling. Consider the following example:
Start C++ section to tut/examples/tut151.flx[1 /1 ]
     1: include "std";
     2: 
     3: proc bad_calc(err: int -> void)
     4: {
     5:   // do some work, detect an error
     6:   err 1; // throw exception
     7: }
     8: 
     9: proc main
    10: {
    11:   proc err(errno:int)
    12:   {
    13:     print "error "; print errno;
    14:     print " -- aborting"; endl;
    15:     goto resume;
    16:   }
    17:   bad_calc err of (int);
    18:   print "no error"; endl;
    19: resume:>
    20:   print "error handled, continuing"; endl;
    21: }
    22: main;
    23: 
End C++ section to tut/examples/tut151.flx[1]
Here, we establish a handler for an error, which is effectively established at the label resume: the handler is passed explicitly to the routine which may 'raise' it.