Hi all - <br><br>I wrote a few macros that are meant to be syntactic sugars for servlet modules but appear to run into macro expansion problems that appears to be a depth program, or a conflict with macro provide or something else... not sure the actual causes.
<br><br>What I am trying to do is to write something like following: <br><br>(module webtest1 mzscheme <br> (require "syntax-util.scm") ; contains the syntactic sugar macros <br> (servlet ; this is the form that will expand to the 3 required form for servlets - interface-version is hard coded; need to define time-out & main
<br> (time-out +inf.0) <br> (main <br> `(p "hello world")))<br> )<br><br>The goal is to have it expand to: <br><br>(module webtest1 mzscheme <br> (require "syntax-util.scm") <br> (define interface-version 'v1)
<br> (define timeout +inf.0) <br> (define (start initial-request) <br> `(p "hello world")) <br> (provide (all-defined))) <br><br>I expanded my macros manually and it seem to produce the form above without problems. The actual expansion turns out to be:
<br><br>> (syntax-object->datum (expand '(module webtest1 mzscheme <br> (require syntax-util) <br> (servlet <br> (time-out +inf.0) <br> (main <br>
`(p "hello world"))))))<br><br>(module webtest1 mzscheme<br> (#%plain-module-begin<br> (require-for-syntax mzscheme)<br> (require syntax-util)<br> (define-values (timeout) (#%datum . +inf.0))
<br> (define-values (start) (lambda (initial-request) '(p "hello world")))<br> (define-values (interface-version) 'v1)<br> (provide (all-defined))))<br><br>Which is the same when I manually expand the module with direct definition of timeout/start/interface-version.
<br><br>> (syntax-object->datum (expand '(module webtest1 mzscheme <br> (require syntax-util) <br> (begin <br> (define timeout +inf.0)<br> (define (start initial-request)
<br> `(p "hello world"))<br> (define interface-version 'v1) <br> (provide (all-defined))))))<br><br>(module webtest1 mzscheme<br> (#%plain-module-begin
<br> (require-for-syntax mzscheme)<br> (require syntax-util)<br> (define-values (timeout) (#%datum . +inf.0))<br> (define-values (start) (lambda (initial-request) '(p "hello world")))<br> (define-values (interface-version) 'v1)
<br> (provide (all-defined))))<br><br>The expansions appear to be the same, but when I require the first module, I was only able to get the definition for interface-version, but timeout and start are undefined. Why would this be the case?
<br><br>The macros in question are following:<br><br>(module syntax-util mzscheme <br> (provide (all-defined)) <br><br> (define-syntax (time-out stx) <br> (syntax-case stx () <br> ((_ value) <br> #'(define timeout value))))
<br> <br> (define-syntax (main stx) <br> (syntax-case stx () <br> ((_ body ...) <br> #`(define start <br> (lambda (initial-request) <br> body ...))))) <br> <br> (define-syntax servlet
<br> (lambda (stx) <br> (syntax-case stx () <br> ((_ body ...) <br> #`(begin <br> body ...<br> (define interface-version 'v1)<br> (provide (all-defined)) <br>
))))) <br> )<br><br>Thanks,<br>yinso <br><br>-- <br><a href="http://www.yinsochen.com">http://www.yinsochen.com</a><br>...continuous learning...