throw signals an exception value to the nearest enclosing
catch that matches it, or invokes
the debugger otherwise.
Syntax
(throw ⟨expr⟩)
Semantics
- The argument must have a known exception type, typically from
define-exception. - Control transfers out of the current computation until a matching
catchhandler is found. - Exception values can be constructed before they are thrown.
throwis not currently polymorphic without an explicit type.
Example
(define (crack egg)
(match egg
((Xenomorph)
(throw (DeadlyEgg egg)))
(_ egg)))