[<<][staapl][>>][..]
Wed Mar 5 16:44:26 CET 2008

for-template and scheme/base

setting: 2 modules
  test.ss   (require (for-syntax "rep.ss"))
  rpn-tx.ss (require (for-template mzscheme))

when test.ss is #lang mzscheme, or #lang scheme, this works. however,
for #lang scheme/base i get an error:

/home/tom/scat/scat/rpn/test.ss:8:2: compile: bad syntax; function application is not allowed, because no #%app syntax transformer is bound in: (lambda (stx) (syntax-case stx () ((_ . code) ((rpn-represent) (syntax code)))))

after adding a 'for-syntax mzscheme' or 'for-syntax scheme/base' in
test.ss it works.

what works is to add (for-template scheme/base) in rep-tx.ss and
(for-syntax scheme/base) in test.ss

looks like there's different phase 1 bindings for mzscheme and
scheme/base.. or something.. i don't really understand.

i try to explain:

tom@del:~/phase-test$ cat tx.ss
#lang scheme/base
(provide gen-code)
(require (for-template scheme/base))
(define (gen-code) #'(+ 1 2))

tom@del:~/phase-test$ cat use.ss
#lang scheme/base
(require (for-syntax "tx.ss" scheme/base))
(define-syntax gen
  (lambda (stx) (gen-code)))

why are both requires of scheme/base needed?

EDIT: take a look at these expands:

box> (expand-syntax #'(module broem scheme/base (define foo 123)))
(module broem scheme/base
  (#%module-begin (define-values (foo) '123) (#%app void)))
box> (expand-syntax #'(module broem mzscheme (define foo 123)))
(module broem mzscheme
  (#%plain-module-begin
   (#%require (for-syntax scheme/mzscheme))
   (define-values (foo) '123)))

mzscheme has mzscheme included in phase +1, while scheme/base does
not. (what's the difference between %plain-module-begin and
%module-begin ?




[Reply][About]
[<<][staapl][>>][..]