[plt-scheme] Help with syntax certification

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Wed Feb 27 21:17:04 EST 2008

The short answer is that `scheme/require-transform' needs to implement
and provide more certificate-related functionality. I think you would
also like to have support for `require'-form "macro", as opposed to the
current "micro" transformers, which can automatically manage
certificates in the same way as macros in expression and definition
contexts. I'll work on it as soon as possible.

Matthew

At Wed, 27 Feb 2008 17:18:30 -0500, "Sam TH" wrote:
> 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
> _________________________________________________
>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme


Posted on the users mailing list.