-
Notifications
You must be signed in to change notification settings - Fork 1
/
state-structs.scm
44 lines (32 loc) · 1.06 KB
/
state-structs.scm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#lang racket
(provide (all-defined-out))
; declare: (cfuncs f g h i)
; call: (cfuncs-return cfuncstructval)
(struct cfuncs
(
return
break
continue
catch
))
(define cfuncs-update-return
(lambda (cfuncsinstance newfunc)
(struct-copy cfuncs cfuncsinstance [return newfunc])))
(define cfuncs-update-break
(lambda (cfuncsinstance newfunc)
(struct-copy cfuncs cfuncsinstance [break newfunc])))
(define cfuncs-update-continue
(lambda (cfuncsinstance newfunc)
(struct-copy cfuncs cfuncsinstance [continue newfunc])))
(define cfuncs-update-catch
(lambda (cfuncsinstance newfunc)
(struct-copy cfuncs cfuncsinstance [catch newfunc])))
(define cfuncs-wipe-all-but-catch
(lambda (cfuncsinstance)
(cfuncs-update-break (cfuncs-update-continue (cfuncs-update-return cfuncsinstance identity)
identity)
identity)))
(define identity-catch
(lambda (a b)
(error "called identity catch" a b)))
(define empty-cfuncs (cfuncs identity identity identity identity-catch))