[plt-scheme] provide-for-syntax?

From: YC (yinso.chen at gmail.com)
Date: Wed May 23 18:58:35 EDT 2007

Hi all -

Is there something analogous to (provide) but for the transformation
environment, e.g. provide-for-syntax?

It seems that making a module a custom language doesn't automatically
introduce the definitions into transformation environment, i.e. I still need
to use (require-for-syntax).  The example below demonstrates the need.  Am I
missing something?

Thanks,
yinso

; custom language module foo
(module foo mzscheme
  (define (show a . rest)
    (map display (cons a rest))
    (newline))
  (define (add a b)
    (show a " " b)
    (+ a b))
  (provide (all-defined) (all-from mzscheme)))

; use foo as the language
(module bar foo
  ; require-for-syntax is needed to make it work...
  (require-for-syntax foo)
  ; comment above and get error =>
  ; expand: unbound variable in module (transformer environment) in: add
  (define-syntax bar
    (lambda (stx)
      (syntax-case stx ()
        ((_ val1 val2)
         (with-syntax ((result (datum->syntax-object
                                #'stx
                                (add (syntax-object->datum #'val1)
                                     (syntax-object->datum #'val2)))))
           #'result)))))
  (provide (all-defined)))

; test
(require bar)
(bar 5 10)
; => 15 with (require-for-syntax foo)
; => error without
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20070523/37d8e402/attachment.html>

Posted on the users mailing list.