-
Notifications
You must be signed in to change notification settings - Fork 3
/
actor.scm
51 lines (43 loc) · 994 Bytes
/
actor.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
40
41
42
43
44
45
46
47
48
49
50
51
;;
;; actor.scm (meta-actor facilities)
;;
(define sink-beh (BEH _))
(define a-sink (CREATE sink-beh))
(define a-printer
(CREATE
(BEH msg
(seq (print msg) (newline))
)))
(define fwd-beh
(lambda (cust)
(BEH msg
(SEND cust msg)
)))
(define once-beh
(lambda (cust)
(BEH msg
(SEND cust msg)
(BECOME sink-beh)
)))
(define label-beh
(lambda (cust label)
(BEH msg
(SEND cust (cons label msg))
)))
(define tag-beh
(lambda (cust)
(BEH msg
(SEND cust (cons SELF msg))
)))
(define a-testcase
(CREATE
(BEH _
;(seq (print 'SELF) (debug-print SELF) (newline))
(define a-fwd (CREATE (fwd-beh a-printer)))
(define a-label (CREATE (label-beh a-fwd 'tag)))
(define a-once (CREATE (once-beh a-label)))
(SEND a-fwd '(1 2 3))
(SEND a-once '(a b c))
(SEND a-once '(x y z))
)))
;(define a-testfail (CREATE (BEH _ (SEND a-printer 'foo) (FAIL 420) (SEND a-printer 'bar))))