From 0c07fb3b0e2202d8ca4045f73afb7a0a149ec12a Mon Sep 17 00:00:00 2001 From: Tony Garnock-Jones Date: Mon, 13 Aug 2012 17:06:22 -0400 Subject: [PATCH] Introduce "?" as identifier-syntax for "(wild)" --- chat-os2-paper.rkt | 6 ++---- chat-os2.rkt | 4 ++-- os2.rkt | 6 ++++++ 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/chat-os2-paper.rkt b/chat-os2-paper.rkt index 651c3ca..2f32fdf 100644 --- a/chat-os2-paper.rkt +++ b/chat-os2-paper.rkt @@ -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) diff --git a/chat-os2.rkt b/chat-os2.rkt index fbda599..39ea66e 100644 --- a/chat-os2.rkt +++ b/chat-os2.rkt @@ -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) diff --git a/os2.rkt b/os2.rkt index cc9c72b..bd06249 100644 --- a/os2.rkt +++ b/os2.rkt @@ -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.