Add spawn/stateless to syndicate/monolithic
This commit is contained in:
parent
6cac704bc5
commit
fdf0fa8cf6
|
@ -7,7 +7,8 @@
|
||||||
event?
|
event?
|
||||||
action?
|
action?
|
||||||
clean-transition
|
clean-transition
|
||||||
spawn))
|
spawn
|
||||||
|
spawn/stateless))
|
||||||
(require "monolithic/scn.rkt")
|
(require "monolithic/scn.rkt")
|
||||||
(require "monolithic/core.rkt")
|
(require "monolithic/core.rkt")
|
||||||
(provide (all-from-out "lang.rkt")
|
(provide (all-from-out "lang.rkt")
|
||||||
|
|
|
@ -16,7 +16,8 @@
|
||||||
(struct-out monolithic-wrapper)
|
(struct-out monolithic-wrapper)
|
||||||
wrap-monolithic-state
|
wrap-monolithic-state
|
||||||
wrap-monolithic-behaviour
|
wrap-monolithic-behaviour
|
||||||
(rename-out [spawn-monolithic spawn]))
|
(rename-out [spawn-monolithic spawn])
|
||||||
|
(rename-out [spawn-monolithic/stateless spawn/stateless]))
|
||||||
|
|
||||||
(require racket/match)
|
(require racket/match)
|
||||||
(require (only-in racket/list flatten))
|
(require (only-in racket/list flatten))
|
||||||
|
@ -136,3 +137,21 @@
|
||||||
(differentiate-outgoing (wrap-monolithic-state initial-state-exp)
|
(differentiate-outgoing (wrap-monolithic-state initial-state-exp)
|
||||||
(clean-actions initial-action-tree-exp))
|
(clean-actions initial-action-tree-exp))
|
||||||
#f)))]))
|
#f)))]))
|
||||||
|
|
||||||
|
(define-syntax spawn-monolithic/stateless
|
||||||
|
(syntax-rules ()
|
||||||
|
[(_ #:name name-exp behavior-exp initial-action-tree-exp)
|
||||||
|
(spawn-monolithic #:name name-exp
|
||||||
|
(stateless-behavior-wrap behavior-exp)
|
||||||
|
(void)
|
||||||
|
initial-action-tree-exp)]
|
||||||
|
[(_ behavior-exp initial-action-tree-exp)
|
||||||
|
(spawn-monolithic (stateless-behavior-wrap behavior-exp)
|
||||||
|
(void)
|
||||||
|
initial-action-tree-exp)]))
|
||||||
|
|
||||||
|
(define ((stateless-behavior-wrap b) e state)
|
||||||
|
(match (b e)
|
||||||
|
[#f #f]
|
||||||
|
[(? quit? q) q]
|
||||||
|
[actions (transition state actions)]))
|
Loading…
Reference in New Issue