Added exception handling words.
[scheme.forth.jl.git] / catch-throw.4th
1 \ Exception handling
2
3 variable handler
4
5 : catch ( cfa -- exception# | 0 )
6     psp@ >R
7     handler @ >R
8     rsp@ handler !
9     execute
10     R> handler !
11     R> drop
12     0
13 ;
14
15 : throw ( ... exception# -- ... exception# )
16     ?dup 0= if exit then
17
18     handler @ rsp!
19     R> handler !
20     
21     R> swap >R
22     psp! drop R>
23 ;