<HTML><FONT FACE=arial,helvetica><FONT SIZE=2 FAMILY="SANSSERIF" FACE="Arial" LANG="0">Hi!<BR>
<BR>
<BLOCKQUOTE TYPE=CITE style="BORDER-LEFT: #0000ff 2px solid; MARGIN-LEFT: 5px; MARGIN-RIGHT: 0px; PADDING-LEFT: 5px">> The full example is rather long, but complains:<BR>
> compile: bad syntax; function application is not allowed, because no #%app <BR>
> syntax transformer is bound in: ...<BR>
<BR>
After giving it some thought, I don't have any good guesses.</BLOCKQUOTE><BR>
<BR>
I have managed to fix my macro, but also to formulate a far more consise example of this problem (given below). In the following example, if I "inline" the helper in my macro, everything behaves correctly. But in the case below, I get the following error when my macro is used within a module:<BR>
a.ss:8:5: compile: bad syntax; function application is not allowed, because no #%app syntax transformer is bound in: (cons 1 2)<BR>
<BR>
As before, when this macro is used in the REPL in DrScheme, the macro "works". In this case, the macro is expanded, and the result is evaluated to (1 . 2) as one would expect.<BR>
<BR>
The trick to fixing my complte define-struct/prop macro was to move the "helper" code into the body of my syntax case macro.<BR>
<BR>
In principle, I could, sort of, understand that there is a problem with referencing a binding of cons in an instantiation of mzscheme in a different phase, and feeding this syntax object back to the value-time environment of module c. But why does it "work" in the REPL, if that is the case?<BR>
<BR>
Jim<BR>
<BR>
---------------------------<BR>
; c.ss<BR>
<BR>
(module c mzscheme<BR>
<BR>
(require "b.ss")<BR>
<BR>
(my-cons 1 2))<BR>
<BR>
---------------------------<BR>
; b.ss<BR>
<BR>
(module b mzscheme<BR>
<BR>
(provide my-cons)<BR>
<BR>
(require-for-syntax "a.ss")<BR>
<BR>
(define-syntax (my-cons stx)<BR>
(syntax-case stx ()<BR>
((_ a b)<BR>
(helper #`a #`b)))))<BR>
<BR>
---------------------------<BR>
; a.ss<BR>
<BR>
(module a mzscheme<BR>
<BR>
(provide helper)<BR>
<BR>
(define (helper first rest)<BR>
#`(cons #,first #,rest)))<BR>
</FONT></HTML>