Has approximately the conventional meaning -- evaluate the first expression (the attempt), but, if it throws a Throwable that matches the catch-clause's pattern, then evaluate the second expression (the handler). If the attempt exits in any other way, then the outcome of the catch expression is the outcome of the atttempt. If the attempt does throw a matching Throwable, then the outcome of the catch expression is the outcome of the handler.
One problematic case: if the pattern match of the catch-pattern against the Throwable itself throws a new Throwable rather than matching or not matching. In this case, we continue throwing (ie, rethrow) the original Throwable, under the assumption that the original Throwable is more important than a Throwable that happened in trying to catch it. Unlike Java, in E one cannot use the catch expression to catch all non-local exits, even if they would match a catch-clause's pattern. Catch expressions cannot intercept an ejection. Likewise, if the match of the catch pattern performs a non-local escape, that exit proceeds instead of the original non-local exit. The attempt is in one scope box and the pattern and handler together are in another. |
||||||||||||||||||||||||
Unless stated otherwise, all text on this page which is either unattributed or by Mark S. Miller is hereby placed in the public domain.
|