Abstract
The fifth lecture began with an in-depth look at the notions of exceptions and exception handlers introduced in the second lecture. We showed how to introduce exception handling into a functional language, in which cases it can be useful, and how to give it formal semantics through under-context reduction rules. Next, we introduced program-defined effects and their effect handlers as they appear in the OCaml language version 5 : as a generalization of exceptions where the handler receives not only the value of the effect, but also a delimited continuation allowing calculation to resume where the exception was raised. Behind their apparent simplicity, effect handlers are a powerful control operator, as we have shown on several examples : inversion of control over iterators ; transformation of output effects ; and implementation of cooperativethreads, including synchronous message communication. Finally, we have defined a semantic by subcontext reduction for a small language of effects and effect handlers, and sketched a CPS transformation for this language.