<br>
<div class="gmail_quote"><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div><div class="h5">
<br></div></div>
It's true that macro arguments are syntax objects, and the rest of your tutorial shows one way of interpreting a syntax object as an "expression at compile time" (as opposed to "expression at run time", which is what most macro arguments are).<br>
<br>
It's also possible to do the evaluation immediately, instead of trampolining through define-syntax. See syntax-local-eval from unstable/syntax. It creates an internal definition context, uses syntax-local-bind-syntaxes to evaluate and bind the expression to a temporary name, and syntax-local-value to extract the value.<font color="#888888"></font><br>
</blockquote></div><br><br>Excellent! This is so much simpler. Thanks!<br><br>Now we can write the following (also using to-syntax to simplify a little bit more):<br><br>#lang racket<br><br>(require (for-syntax unstable/syntax))<br>
<br>(define-syntax (define-me2 stx)<br> (syntax-case stx ()<br> [(_ id-maker var val)<br> (with-syntax ([id (to-syntax<br> #:stx #'var<br> (string->symbol<br> ((syntax-local-eval #'id-maker)<br>
(symbol->string (syntax->datum #'var))<br> )))])<br> #'(define id val))]))<br><br>(define-me2 (ë(id-str)(string-append id-str "-me2"))<br> a 2)<br>
<br>a-me2<br><br><br><br>-- <br>Laurent<br><br>