CS 541 Lecture -*-Outline-*- * Sequencers (Ch. 8) ** Jumps (8.1) Q: What kinds of complications do jumps (gotos) entail? enough to leave them out? ** Escapes (8.2) exit, break, continue, return Q: Are exits better than jumps? Why? ** Exceptions (8.3) Q: What practical problems are there with the way that the Unix system calls tell their caller about errors? Q: What is an exception? Is it always an error? Q: Why can't exceptions be ignored? terms: raise = signal, handle = catch *** termination model the command signalling an exception cannot be resumed. in implementation, raise turns into search for handler, followed by jump to it call stack frame(s) lost in the process *** resumption model after the handler does something (e.g. change variables) can resume execution following the raise statement (in Eiffel, start the whole call over) can be implemented by passing the handler to the statement, then raise turns into a call of the handler, resume is return from that call *** comparison resumption model implies overhead on normal calls (passing handlers) termination model faster in normal case, also more common (hard to do useful resumption) *** propogation and types in Ada and ML the exceptions that a procedure can raise are not part of its type. if an exception occurs in a procedure and is not handled, that procedure is terminated, and search for handler continues in the caller. (This is called propogation) in CLU, exceptions are part of procedure types no propogation inspired by specification considerations.