The Lambda Lab
/
projects
/
scheme.forth.jl.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
7ea8812
)
Added exception handling words.
author
Tim Vaughan
<tgvaughan@gmail.com>
Thu, 3 Nov 2016 19:51:09 +0000
(08:51 +1300)
committer
Tim Vaughan
<tgvaughan@gmail.com>
Thu, 3 Nov 2016 19:51:09 +0000
(08:51 +1300)
catch-throw.4th
[new file with mode: 0644]
patch
|
blob
diff --git a/catch-throw.4th
b/catch-throw.4th
new file mode 100644
(file)
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>
+;