From: Tim Vaughan Date: Thu, 3 Nov 2016 19:51:09 +0000 (+1300) Subject: Added exception handling words. X-Git-Url: https://thelambdalab.xyz/gitweb/index.cgi?p=scheme.forth.jl.git;a=commitdiff_plain;h=eb78b40c04fd1d78cdb0a3050575c9acdf4c6cbb Added exception handling words. --- diff --git a/catch-throw.4th b/catch-throw.4th new file mode 100644 index 0000000..5c66df3 --- /dev/null +++ b/catch-throw.4th @@ -0,0 +1,23 @@ +\ Exception handling + +variable handler + +: catch ( cfa -- exception# | 0 ) + psp@ >R + handler @ >R + rsp@ handler ! + execute + R> handler ! + R> drop + 0 +; + +: throw ( ... exception# -- ... exception# ) + ?dup 0= if exit then + + handler @ rsp! + R> handler ! + + R> swap >R + psp! drop R> +;