Vocabulary
continuations

Inputs
trya quotation with stack effect ( ..a -- ..a )
cleanup-alwaysa quotation with stack effect ( ..a -- ..b )
cleanup-errora quotation with stack effect ( ..b -- ..b )


Outputs
None

Word description
Calls the try quotation. If no error is thrown, calls cleanup-always without restoring the data stack. If an error is thrown, restores the data stack, calls cleanup-always followed by cleanup-error, and rethrows the error.

See also
recover, finally

Definition


: cleanup ( try cleanup-always cleanup-error -- )
[ compose [ dip rethrow ] curry recover ] [ drop ] 2bi call
; inline