Match state rather than straight binding it
This commit is contained in:
parent
b96114f774
commit
37f242874b
|
@ -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 ...]))))))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue