CSC448: Code Generation Revisited: Exceptions [126/133] Previous pageContentsNext page

The traditional solution to dealing with exceptional cases is to distinguish normal values from exceptional values, and to require every piece of code to check for exceptional values. However, this is neither robust nor manageable, even in modestly sized systems, nor is it appropriate for processing asynchronous errors.

Exceptions provide a control-flow mechanism that is quite different from other control-flow constructs found in common languages.

Exceptions provide a form of non-local jump where the destination is unknown: we must provide an exception name and the runtime system will jump to the most recent exception handler block that we are currently inside.

In addition, the runtime system may:

Some examples:

There are many tricky details:

Previous pageContentsNext page