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
(syntax-rules ()
((_ old-state [pattern body ...] ...)
((_ old-state-pattern [pattern body ...] ...)
(on-message (match-lambda [pattern #t] ... [_ #f])
(lambda (message old-state)
(match-define old-state-pattern old-state)
(match message
[pattern body ...] ...))))))
(define-syntax meta-message-handler
(syntax-rules (=>)
((_ old-state [(raw-pattern => pattern) body ...])
((_ old-state-pattern [(raw-pattern => pattern) body ...])
(on-meta-message raw-pattern
(lambda (meta-message old-state)
(match-define old-state-pattern old-state)
(match meta-message
[pattern body ...]))))))