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 (cout (term->bytes
`(,who ,did-what)))))) `(,who ,did-what))))))
(list (list
(role (topic-publisher (role (topic-publisher `(,me says ,?)))
`(,me says ,(wild)))) (role (topic-subscriber `(,? says ,?))
(role (topic-subscriber
`(,(wild) says ,(wild)))
#:topic t #:topic t
#:on-presence (announce t 'arrived) #:on-presence (announce t 'arrived)
#:on-absence (announce t 'departed) #:on-absence (announce t 'departed)

View File

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

View File

@ -77,6 +77,9 @@
non-wild? non-wild?
ground? ground?
;; Identifier-syntax for (wild)
?
;; Reexports from racket/match for convenience ;; Reexports from racket/match for convenience
(all-from-out racket/match) (all-from-out racket/match)
@ -294,6 +297,9 @@
(define-syntax-rule (yield-macro #:state state-pattern body ...) (define-syntax-rule (yield-macro #:state state-pattern body ...)
(yield (match-lambda [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. ;; Smarter constructors for transitions and preactions.