:: — Error guard
kinds::handler catches later errors of the named kinds in a dfn, including errors in its later bodies, and gives the handler’s value as the dfn’s result. A kind’s name is a case-insensitive string, such as "DOMAIN". A vector of names catches each of those kinds. ∞:: catches every kind except INTERRUPT, TIMEOUT and UNSUPPORTED.
{∞::42 ◇ 1÷ω}'a' ⍝ 42
{"DOMAIN"::0 ◇ ÷ω}'a' ⍝ 0BPL raises the kinds SYNTAX, DOMAIN, LENGTH, LIMIT, RANK, INDEX, VALUE, IO, INTERRUPT, TIMEOUT and UNSUPPORTED. A program can raise a new kind with •signal, and a guard catches it by name.
In the handler, $e is the caught error: a record with kind, message, and the source, line and column where the error happened.
{∞::$e.kind ◇ ÷ω}'a' ⍝ "DOMAIN"•signal $e raises the caught error’s kind and message again at the •signal call. $e.line and $e.column still give the position where the error first happened.
In the handler, local names have the values they had when the error happened. Nothing is rolled back, including outer writes and output. The selected guard is inactive in its handler.
{x←1 ◇ ∞::x ◇ x←2 ◇ 1÷ω}'a' ⍝ 2A guard that names INTERRUPT ends the interrupt, and its handler runs until another interrupt. A guard can name TIMEOUT, but the deadline has still passed, and the handler stops the next time BPL checks the deadline.
APL difference: Dyalog’s guards take error numbers. BPL’s take names.