CS 15-212: Fundamental Structures of Computer Science II
Exceptions play an important role in the system of static and dynamic checks that make SML a safe language. Exceptions are the first type of "effect" that we will encounter; they may cause an evaluation to be interrupted or aborted. We've already seen simple uses of exceptions several times in the course, primarily to signal that invariants are violated or exceptional ``boundary cases'' are encountered. We now look a little more closely at what exceptions are and how they can be used. In addition to signalling error conditions, exceptions can sometimes also be used in "backtracking" search procedures or other patterns of control where a computation needs to be partially "undone."