Just want to verify a quick point w.r.t the solution: <br><br>My understanding is that if an identifier is "known" then it would evaluate to the correct form - for example:<br><br>(lambda (stx) <br> (syntax-case stx ()
<br> ((_ foo ...) <br> #'(begin <br> (_ foo ...))))) <br><br>The begin keyword is "okay" (without having to provide context) because it is already an known identifier. But if I am to generate my own name then I need to use the datum->syntax-object binding.
<br><br>So why isn't '(provide ...) "okay"? <br><br>Thanks,<br>yinso <br><br><div><span class="gmail_quote">On 4/24/07, <b class="gmail_sendername">Yin-So Chen</b> <<a href="mailto:yinso.chen@gmail.com">
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;">Thanks!! I was scratching my head trying to figure out where things went wrong and went down the define-macro path... thanks for pointing out my misunderstanding ;)
<br><br>Very appreciated ;)<br><br>yinso <div><span class="e" id="q_112262ebc5af7f2c_1"><br><br><div><span class="gmail_quote">
On 4/24/07, <b class="gmail_sendername">Matthew Flatt</b> <<a href="mailto:mflatt@cs.utah.edu" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">mflatt@cs.utah.edu</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;">
At Tue, 24 Apr 2007 13:35:45 -0700, "Yin-So Chen" wrote:<br>> (define-syntax require-prefix<br>> (lambda (stx)<br>> (syntax-case stx ()<br>> ((_ req-clause)<br>> (with-syntax ((pref (datum->syntax-object stx (string->symbol
<br>> "a:"))))<br>> #`(require (prefix pref req-clause))))<br><br>The context of the `(prefix ...)' form determines the binding context<br>of the imports. So, you need to give the `(prefix ...)' part the
<br>original context.<br><br>Here's one way to do it:<br><br> (define-syntax require-prefix<br> (lambda (stx)<br> (syntax-case stx ()<br> ((_ req-clause)<br> (with-syntax ((pref-req-clause (datum->syntax-object
<br> #'req-clause<br> `(prefix a: ,#'req-clause)<br> #'req-clause)))<br> #'(require pref-req-clause)))
<br> ((_ req-clause rest ...)<br> #'(begin<br> (_ req-clause)<br> (_ rest ...))))))<br><br><br>Matthew<br><br></blockquote></div><br><br clear="all"><br></span></div><span class="sg">
-- <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></blockquote></div><br><br clear="all"><br>-- <br><a href="http://www.yinsochen.com">http://www.yinsochen.com</a><br>...continuous learning...