From fdf0fa8cf6562a328b48e26d3c6ac6d695aa300e Mon Sep 17 00:00:00 2001 From: Sam Caldwell Date: Mon, 25 Jul 2016 14:48:41 -0400 Subject: [PATCH] Add spawn/stateless to syndicate/monolithic --- racket/syndicate/monolithic.rkt | 3 ++- racket/syndicate/monolithic/core.rkt | 21 ++++++++++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/racket/syndicate/monolithic.rkt b/racket/syndicate/monolithic.rkt index 1657693..ff9aa83 100644 --- a/racket/syndicate/monolithic.rkt +++ b/racket/syndicate/monolithic.rkt @@ -7,7 +7,8 @@ event? action? clean-transition - spawn)) + spawn + spawn/stateless)) (require "monolithic/scn.rkt") (require "monolithic/core.rkt") (provide (all-from-out "lang.rkt") diff --git a/racket/syndicate/monolithic/core.rkt b/racket/syndicate/monolithic/core.rkt index 0cb94f0..7b89eee 100644 --- a/racket/syndicate/monolithic/core.rkt +++ b/racket/syndicate/monolithic/core.rkt @@ -16,7 +16,8 @@ (struct-out monolithic-wrapper) wrap-monolithic-state wrap-monolithic-behaviour - (rename-out [spawn-monolithic spawn])) + (rename-out [spawn-monolithic spawn]) + (rename-out [spawn-monolithic/stateless spawn/stateless])) (require racket/match) (require (only-in racket/list flatten)) @@ -136,3 +137,21 @@ (differentiate-outgoing (wrap-monolithic-state initial-state-exp) (clean-actions initial-action-tree-exp)) #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)])) \ No newline at end of file