[plt-scheme] Help with syntax certification

From: Sam TH (samth at ccs.neu.edu)
Date: Wed Feb 27 17:18:30 EST 2008

I'm trying to use the new require expanders, and I'm having trouble
with syntax certificates.  Given the following modules:

--------------------------------------------

(module m scheme/base

(require (for-syntax scheme/base scheme/require-transform))

(define-for-syntax (splice-requires specs)
  (define subs (map (compose cons expand-import) specs))
  (values (apply append (map car subs)) (apply append (map cdr subs))))

(define-syntax define-module
  (lambda (stx)
    (syntax-case stx ()
      [(_ nm spec ...)
       (syntax/loc stx
         (define-syntax nm
           (make-require-transformer
            (lambda (stx)
              (splice-requires (list (syntax-local-introduce
(quote-syntax spec)) ...))))))])))

(define-syntax planet/multiple
  (make-require-transformer
   (lambda (stx)
     (syntax-case stx ()
       [(_ plt files ...)
        (let ([mk (lambda (spc)
                    (syntax-case spc (prefix-in)
                      [e
                       (string? (syntax-e #'e))
                       (datum->syntax spc `(planet ,#'e ,#'plt) spc)]
                      [(prefix-in p e)
                       (datum->syntax spc `(prefix-in ,#'p (planet
,#'e ,#'plt)) spc)]))])
          (splice-requires (map mk (syntax->list #'(files ...)))))]))))


(provide galore)
;; why is this neccessary?
;(provide planet/multiple)

(define-module galore
  (planet/multiple ("soegaard" "galore.plt" 3 6)
   (prefix-in table: "table.ss")
   (prefix-in set: "set.ss"))))

(module n scheme/base
  (require 'm)
  (require (galore)))

---------------------------------------------------------

I get the error:

compile: access from an uncertified context to unexported syntax from
module: 'm in: planet/multiple

If I provide `planet/multiple', the error goes away.  But what's the
right solution here?  On Ryan's advice, I tried changing the
definition of `define-module' to the following:

(define-syntax define-module
  (lambda (stx)
    (syntax-case stx ()
      [(_ nm spec ...)
         (syntax/loc stx
           (define-syntax nm
             (make-require-transformer
              (with-syntax ([(spec ...) (map (syntax-local-certifier)
(syntax->list #'(spec ...)))])
                (lambda (stx)
                  (splice-requires (list (syntax-local-introduce
(quote-syntax spec)) ...)))))))])))

Then I get the even stranger error:

 _: variable used twice in pattern in: prefix-in

pointing to the second occurrence of `prefix-in' in the definition of
`galore'.  At that point, we were puzzled.

Thanks,
-- 
sam th
samth at ccs.neu.edu


Posted on the users mailing list.