Catch
Fredrik Linder
qtxfklr@REDACTED
Tue Nov 20 15:44:23 CET 2001
Hi
At the Erlang Workshop in Florence did a discussion about separating
code for normal execution from code for exception(al?) execution take
place.
Now I am wondering what the Erlang community think about a proposal that
came up.
The proposal is to extend where a catch might be placed. Note that the
current use of catches could still be valid.
Proposal:
case <expr> of
NormalMatch1 ->
blabla;
NormalMatch2 ->
blabla
catch
{'EXIT', Reason} ->
blabla;
ExceptionMatch2 ->
blabla
end
If this feels like a good way of doing it, then maybe also extend this
to receive statements:
receive
NormalMatch ->
blabla
after
Time ->
blabla
catch
{'EXIT', Pid, Reason} ->
blabla;
SignalMatch ->
blabla
end
By introducing an 'EXIT' record could this be extended further:
-record('EXIT', {pid, reason}).
recieve|case <expr> of
NormalMatch ->
blabla
catch
#'EXIT'{} ->
blabla;
#'EXIT'{pid = Pid} -> % In a case statement is Pid == self()
blabla;
#'EXIT'{reason = Reason} ->
blabla
end
The last suggestion could be implemented as syntactical suger (I guess).
/Fredrik
More information about the erlang-questions
mailing list