[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: module: How to specify indirect exports positively?

Thank you very much for the instructive example-macro.

I have extended it a bit to make it export any number of
module-identifiers without their common prefix ... a functionality
that I'd like to see provided by mzscheme, too, because it's much
shorter than the equivalent rename-syntax. 

Following the working example. I've thrown some comments in just in
case somebody might find this useful.


(module A mzscheme

  (define-syntax provide-prefixless
    ;; <prefix> <identifier>+ -> unspecified
    ;; Export every <identifier> without its local <prefix>.
    (lambda (stx)
      (syntax-case stx ()
        ((_ pre e0 e1 ...)
         (letrec ((prefix  
                   ;; Make Prefix-String.
                     (syntax pre))))
                   ;; <symbol> -> <list>
                   ;;  name -> (prefixed-name name)
                   (lambda (name)
                     (list (string->symbol
                            (string-append prefix
                                           (symbol->string name)))
           (syntax-case (map prefixer
                             (cddr (syntax-object->datum stx))) ()
             (((prefixed-name name) ...)
              (syntax (provide (rename prefixed-name name) 
  (provide-prefixless prefix: x y z)
  (define prefix:x 1)
  (define prefix:y 2)
  (define prefix:z 3))

(require A)
(list x y z)  ;; ==> (1 2 3)