[racket] How to make unit signature macros take prefix into account

From: Nick Main (david.nick.main at gmail.com)
Date: Wed Aug 7 22:00:40 EDT 2013

I have a signature that includes a macro to clean up the use of one of the
procs in the signature.

Two different units with the same signature are used
via define-values/invoke-unit - the second one uses a prefix in the export
sig-spec to differentiate it from the first.
The macro introduced by the second use does not refer to the other proc
using the prefix.

The concrete example:

;; Signature of a message channel
(define-signature message-channel^
   ;; ...
   msg-chan-subscribe   ; ( (msg -> boolean) first? -> thunk)

   ;; Enqueue message(s) for a channel at normal priority
   <--   ; ( msg .. -> void )

   ;; Enqueue message(s) for a channel at high priority
   <++   ; ( msg .. -> void )

   ;; Macro to create a message handler.
   ;; ...
   (define-syntaxes (==>)
     (syntax-rules (msg)
       [(_ match-body ...) (msg-chan-subscribe
                               ([the-message (make-rename-transformer
                               (match msg
                                 match-body ...
                                 [_ #t])))

When (define-values/invoke-unit <some-unit> (import) (export (prefix
diagram message-channel^))) is used it introduces the bindings diagram<-- ,
diagram<++ , diagrammsg-chan-subscribe and diagram==> .

The form

   .. message handlers ..)

expands to (msg-chan-subscribe ...) rather than (diagrammsg-chan-subscribe
...) - and thus it listens to the first (wrong) message channel.

Is there any way to make macros defined in signatures be aware of the
prefix used with the signature ?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20130807/bf0cb0e1/attachment.html>

Posted on the users mailing list.