It seems that (provide) is magical?  If I rewrite my form with provide in main & time-out then I don't need the datum->syntax-object at all, but if I remove the provides to be outside of syntax block then start, timeout, interface-version don't work anymore... 
<br><br>(module syntax-util mzscheme<br>  (provide (all-defined))<br>  <br>  (define-syntax time-out <br>    (lambda (stx) <br>      (syntax-case stx () <br>        ((_ t) <br>         #'(begin <br>             (define timeout t) 
<br>             (provide timeout))))))<br>  <br>  (define-syntax main <br>    (lambda (stx) <br>      (syntax-case stx () <br>        ((_ body ...) <br>         #'(begin <br>             (define (start initial-request) body ...)
<br>             (provide start)))))) <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 interface-version) <br>               )))))<br>  )<br><br>(require syntax-util)<br><br>(module webtest1 mzscheme<br>  (require syntax-util)<br>  (servlet<br>   (time-out +inf.0) <br>   (main `(p "hello world")) 
<br>   )<br>  )<br><br>(require webtest1)<br><br>timeout<br>(start null) <br>interface-version<br><br><div><span class="gmail_quote">On 4/17/07, <b class="gmail_sendername">Yin-So Chen</b> <<a href="mailto:yinso.chen@gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
yinso.chen@gmail.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div><span>Hi Jens - 
<br><br>thanks for the quick reply.  After some more
researching plus looking at your code I realized where my mistakes are
- I thought symbols in a syntax expands out to itself, but apparently
this is not the case (hence my problem has nothing to do with
module/macros).  Instead, I need to use datum->syntax-object to make
sure that timeout in syntax equals timeout in symbol (BTW - thanks for
your example showing below using stx as the context syntax... I was
scratching my head trying to figure out where I can provide a context).
<br><br>However, looking at your code there are some concepts that I don't understand: <br><ul><li>your
code provides syntax name for time-out and main rather than timeout,
start, initial-request, and interface-version - why this also works
without having to convert them to syntax-object?  <br></li><li>how does the nested define-syntax work both in terms of expansion and scoping? </li><li>Aesthetics
and styles aside - is there a reason for nested define-syntax?  (It
looks cool to learn, but I came from the C world where definitions
belong on top level, so want to know why and how I can think in this
fashion) <br></li></ul>Below is what I have right now that works... yours seem shorter ;) <span><br><br>(module syntax-util mzscheme <br>  (provide (all-defined)) <br><br></span>  (define-syntax time-out <span>
<br>    (lambda (stx) <br>      (syntax-case stx () 
<br></span>        ((_ t) <br>         (with-syntax ((timeout (datum->syntax-object stx 'timeout))) <br>           #'(define timeout t))))))<br>  <br>  (define-syntax main <span><br>    (lambda (stx) 
<br>      (syntax-case stx () 
<br>        ((_ body ...) <br></span>         (with-syntax ((start (datum->syntax-object stx 'start))<br>                       (initial-request (datum->syntax-object stx 'intial-request))) <br>           #'(define (start initial-request) 
<br>               body ...))))))<span><br>  <br>  (define-syntax servlet <br>    (lambda (stx) <br>      (syntax-case stx () <br>        ((_ body ...) <br></span>         (with-syntax ((interface-version (datum->syntax-object stx 'interface-version))) 
<br>           #'(begin <span><br>               body ...<br>               (define interface-version 'v1)<br>               (provide (all-defined))))))))) <br><br></span><span>(module webtest1 mzscheme 
<br>  (require syntax-util) <br>
  (servlet <br>   (time-out +inf.0)<br>   (main '(p "hello world")))) <br><br>(require webtest1) <br><br></span>timeout ; => +inf.0<br>interface-version ; =>  'v1 <br>(start null) ; => '(p "hello world")
<br><br>Thanks,<br>yinso <div><span><br><br><br><div><span class="gmail_quote">On 4/17/07, <b class="gmail_sendername">Jens Axel Søgaard</b> <<a href="mailto:jensaxel@soegaard.net" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
jensaxel@soegaard.net</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi Yin-So,<br><br>Here is one way to do it:<br><br>(module syntax-util mzscheme<br>   (provide (all-defined))<br><br>   (define-syntax servlet<br>     (lambda (stx)<br>       (syntax-case stx ()<br>         ((_ body ...)
<br>
          (with-syntax ([time-out (datum->syntax-object stx 'time-out)]<br>                        [main     (datum->syntax-object stx 'main)])<br>            #`(begin<br>                (define-syntax (time-out stx)
<br>                  (syntax-case stx ()<br>                    ((_ value)<br>                     #'(begin<br>                         (define timeout value)<br>                         (provide timeout)))))<br>                (define-syntax (main stx)
<br>                  (syntax-case stx ()<br>                    [(_ body1 (... ...))<br>                     #'(define start<br>                         (lambda (initial-request)<br>                           body1 (... ...)))]))
<br>                body ...<br>                (define interface-version 'v1)<br>                (provide (all-defined))<br>                ))))))<br>   )<br><br>    (require syntax-util)<br><br>  (module webtest1 mzscheme
<br>    (require syntax-util)<br>    (servlet<br>     (time-out +inf.0)<br>     (main `(p "hello world"))<br>     ))<br><br>  (require webtest1)<br><br>  timeout<br><br><br>I moved the definitions of time-out and main into the expansion of
<br>servlet, since they need to be in the scope of the forms of body ... .<br>Note that when expanding into ... one needs to write (... ...).<br><br>Also, to provide a name such as timeout, the provide form must have<br>
the same syntactic context as the definition. The easiest way to ensure
<br>this is, to put a provide-clause next to the definition.<br><br>--<br>Jens Axel Søgaard<br><br><br><br>--<br>Jens Axel Søgaard<br><br></blockquote></div><br><br clear="all"><br></span></div><div><span>
-- <br><a href="http://www.yinsochen.com/" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
http://www.yinsochen.com</a><br>...continuous learning...
</span></div>
</span></div></blockquote></div><br><br clear="all"><br>-- <br><a href="http://www.yinsochen.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://www.yinsochen.com</a><br>...continuous learning...