Match state rather than straight binding it

This commit is contained in:
Tony Garnock-Jones 2012-01-13 18:01:38 -05:00
parent b96114f774
commit 37f242874b
1 changed files with 4 additions and 2 deletions

View File

@ -59,17 +59,19 @@
(define-syntax message-handlers (define-syntax message-handlers
(syntax-rules () (syntax-rules ()
((_ old-state [pattern body ...] ...) ((_ old-state-pattern [pattern body ...] ...)
(on-message (match-lambda [pattern #t] ... [_ #f]) (on-message (match-lambda [pattern #t] ... [_ #f])
(lambda (message old-state) (lambda (message old-state)
(match-define old-state-pattern old-state)
(match message (match message
[pattern body ...] ...)))))) [pattern body ...] ...))))))
(define-syntax meta-message-handler (define-syntax meta-message-handler
(syntax-rules (=>) (syntax-rules (=>)
((_ old-state [(raw-pattern => pattern) body ...]) ((_ old-state-pattern [(raw-pattern => pattern) body ...])
(on-meta-message raw-pattern (on-meta-message raw-pattern
(lambda (meta-message old-state) (lambda (meta-message old-state)
(match-define old-state-pattern old-state)
(match meta-message (match meta-message
[pattern body ...])))))) [pattern body ...]))))))