The Lambda Lab
/
projects
/
scheme.forth.jl.git
/ blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
history
|
raw
|
HEAD
Working on FP arithmetic.
[scheme.forth.jl.git]
/
throw-catch.4th
1
\ Words implementing exception handling
2
3
: catch
4
execute
5
type ;
6
7
: throw ( addr -- )
8
begin
9
R> 2dup 1- ' catch =
10
while
11
drop
12
repeat
13
14
>R
15
;
16
17
: return-depth
18
RSP@ RSP0 - 1- ;
19
20
: stack-trace
21
RSP0 1+ begin
22
dup RSP@ <
23
while
24
dup @ 1- @ >name cr .name
25
1+
26
repeat
27
28
drop
29
;
30
31
: trace
32
cr ." ---" cr
33
." Return stack depth:" return-depth . cr
34
." Stack trace:"
35
stack-trace
36
cr ." ---" cr
37
key drop
38
;