spawn/stateless

This commit is contained in:
Tony Garnock-Jones 2015-03-06 13:23:36 +00:00
parent e4c0f7e95d
commit 0a509dce1b
1 changed files with 12 additions and 0 deletions

View File

@ -41,6 +41,7 @@
make-world
spawn-world
(rename-out [spawn-process spawn])
spawn/stateless
make-spawn-world
world-handle-event
@ -216,6 +217,17 @@
behavior-exp
initial-state-exp))))
(define-syntax-rule (spawn/stateless behavior-exp initial-patch-exp ...)
(spawn-process (stateless-behavior-wrap behavior-exp)
(void)
initial-patch-exp ...))
(define ((stateless-behavior-wrap b) e state)
(match (b e)
[#f #f]
[(? quit? q) q]
[actions (transition state actions)]))
(define-syntax-rule (spawn-world boot-action ...)
(make-spawn-world (lambda () (list boot-action ...))))