[plt-scheme] require-for-syntax issues

From: Felix Klock's PLT scheme proxy (pltscheme at pnkfx.org)
Date: Wed Jul 9 20:24:09 EDT 2003

PLT people-

Its very possible that I just don't understand PLT's model of a syntax 
tower, but I think that the following behavior is inconsistent.

First I defined the following modules:

(module mod3 mzscheme
   (provide opaque-definer)
   (define-struct opaque-object (tag datum))

   (define opaque-definer
     (lambda (stx)
       (syntax-case stx ()
         [(opaque tag datum)
          #'(make-opaque-object tag datum)]

(module mod2 mzscheme
   (provide (all-from mzscheme) opaque-2 opaque-3)
   (require-for-syntax "mod3.scm")

   (define-struct opaque-object (tag datum))

   (define-syntax opaque-3
     (lambda (stx)
       (opaque-definer stx)))

   (define-syntax opaque-2
     (lambda (stx)
       (syntax-case stx () [(opaque tag datum)
                            #'(make-opaque-object tag datum)])))

Then, in the interactions buffer for "mod2", I can execute:
Welcome to DrScheme, version 204.
Language: (module ...).
 > (opaque-3 'food (list 'apple 'banana 'pear))
#(struct:opaque-object food (apple banana pear))

However, when I define the following module "mod1"

(module mod1 mzscheme
   (require "mod2.scm")

   (opaque-2 'food (list 'apple 'banana 'pear))

   (opaque-3 'food (list 'apple 'banana 'pear))

I get the following error on execution:
Welcome to DrScheme, version 204.
Language: (module ...).
. mod3.scm:9:9: compile: bad syntax; function application is not 
allowed, because no #%app syntax transformer is bound in: 
(make-opaque-object (quote food) (list (quote apple) (quote banana) 
(quote pear)))

[when you comment out the "opaque-3" call, then the error goes away]

Why am I able to use "opaque-3" within the interactions buffer for 
"mod2" but not within the body for "mod1" ?  I thought I understood 
section 12 of the manual well enough to diagnose the error message, but 
the most relevant part (12.3.3) only mentions these sorts of problems 
when doing things like (let-syntax ([id (let-syntax ([id expr]) 
body-expr)]) ...)  which AFAICT is not what I'm doing above...

Any opinions from the macro/syntax doctors out there?


Posted on the users mailing list.