catch_expression: catch `(' tag `)' expression ;
catch
establishes a point of return in the invocation stack for a
throw. A throw is an invocation of the throw
method of
the tag. (catch
actually has nothing to do with conditions, but
its usefulness is most profound in condition handling, the reason for it
being discussed in this chapter.)
tag: expression ;
The default implementation of throw
(as provided by the instance
tom.All
) causes execution of the program to resume after the most
recently established catch of the same tag object. Obviously, with
throw
being a method, an object can override it. Be aware
however, that the semantics of the default implementation guarantee not
to return from the invocation of throw
.
Normally, the value returned from a catch
is the value of the
expression
. If a catch is thrown, the value returned is the
value of the argument to the throw
. If the argument to the
throw
is void
, the catch
simply returns the default
element for the type of the value it would otherwise return. For
arguments to throw
other than void
, it is an error if the
type thrown does not match the type caught.
Go to the first, previous, next, last section, table of contents.