### Throwing
[
Datatype throwing
Funcon thrown
Funcon finalise-throwing
Funcon throw
Funcon handle-thrown
Funcon handle-recursively
Funcon catch-else-throw
]
Meta-variables
R, S, T, T′, T′′ <: values
Datatype
throwing ::= thrown(_:values)
*/
Funcon finalise-throwing(X:=>T) : =>T|null-type
~> finalise-abrupting(X)
*/
Funcon throw(V:T) : =>empty-type
~> abrupt(thrown(V))
*/
Funcon
handle-thrown(_:T′=>T, _:T′′=>T) : T′=>T
*/
Rule
X --abrupted( )-> X′
--------------------------------------------------------
handle-thrown(X, Y) --abrupted( )-> handle-thrown(X′, Y)
Rule
X --abrupted(thrown(V′′:values))-> X′
----------------------------------------------
handle-thrown(X, Y) --abrupted( )-> give(V′′, Y)
Rule
X --abrupted(V′:~throwing)-> X′
---------------------------------------------------------
handle-thrown(X, Y) --abrupted(V′)-> handle-thrown(X′, Y)
Rule
handle-thrown(V:T, Y) ~> V
Funcon handle-recursively(X:S=>T, Y:R=>T) : S=>T
~> handle-thrown(X, else(handle-recursively(Y, Y), throw(given)))
*/
Funcon catch-else-throw(P:values, Y:=>T) : =>T
~> else(case-match(P, Y), throw(given))
*/
/*
`thrown(V)` is a reason for abrupt termination.