Introduce "?" as identifier-syntax for "(wild)"

This commit is contained in:
Tony Garnock-Jones 2012-08-13 17:06:22 -04:00
parent 412ac6496b
commit 0c07fb3b0e
3 changed files with 10 additions and 6 deletions

View File

@ -54,10 +54,8 @@
(cout (term->bytes
`(,who ,did-what))))))
(list
(role (topic-publisher
`(,me says ,(wild))))
(role (topic-subscriber
`(,(wild) says ,(wild)))
(role (topic-publisher `(,me says ,?)))
(role (topic-subscriber `(,? says ,?))
#:topic t
#:on-presence (announce t 'arrived)
#:on-absence (announce t 'departed)

View File

@ -18,8 +18,8 @@
(match-define (topic _ (tcp-channel connection-id _ _) _) t)
(define-values (cin cout in-topic out-topic) (tcp-accept t))
(transition 'no-state
(role (topic-publisher `(,connection-id says ,(wild))))
(role (topic-subscriber `(,(wild) says ,(wild)))
(role (topic-publisher `(,connection-id says ,?)))
(role (topic-subscriber `(,? says ,?))
#:topic t
#:on-presence (match t [(topic _ (list who _ _) _)
(unless (equal? who connection-id)

View File

@ -77,6 +77,9 @@
non-wild?
ground?
;; Identifier-syntax for (wild)
?
;; Reexports from racket/match for convenience
(all-from-out racket/match)
@ -294,6 +297,9 @@
(define-syntax-rule (yield-macro #:state state-pattern body ...)
(yield (match-lambda [state-pattern body ...])))
;; A fresh unification variable, as identifier-syntax.
(define-syntax ? (syntax-id-rules () (_ (wild))))
;;---------------------------------------------------------------------------
;; Smarter constructors for transitions and preactions.