I&#39;d like to introduce bindings in a macro.&nbsp; The commented code for with-my-struct is more what I would like to see, but it doesn&#39;t work,&nbsp; The uncommented code works, but is more complex and, well, uglier.&nbsp; Is there a clearer way (i.e. closer to the commented code) to write it?&nbsp; <br>
<br>(module dummy mzscheme<br>&nbsp; <br>&nbsp; (provide (all-defined))<br>&nbsp; <br>&nbsp; (define-struct my-struct (a b c))<br>&nbsp; <br>;&nbsp; (define-syntax with-my-struct<br>;&nbsp;&nbsp;&nbsp; (syntax-rules ()<br>;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ((with-my-struct s<br>;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; expr ...)<br>
;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (let ((a (my-struct-a s))<br>;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (b (my-struct-b s))<br>;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (c (my-struct-c s)))<br>;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; expr ...))))<br>&nbsp; <br>&nbsp; (define-syntax (with-my-struct stx)<br>&nbsp;&nbsp;&nbsp; (syntax-case stx ()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ((with-my-struct s<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; expr ...)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (with-syntax ((a (datum-&gt;syntax-object (syntax with-my-struct) &#39;a))<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (b (datum-&gt;syntax-object (syntax with-my-struct) &#39;b))<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (c (datum-&gt;syntax-object (syntax with-my-struct) &#39;c)))<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (syntax<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (let ((a (my-struct-a s))<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (b (my-struct-b s))<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (c (my-struct-c s)))<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; expr ...))))))<br><br>&nbsp; <br>&nbsp; (define (test-with-my-struct)<br>&nbsp;&nbsp;&nbsp; (let ((s (make-my-struct 1 2 3)))<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (with-my-struct s<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (printf &quot;a = ~a, b = ~a, c = ~a~n&quot; a b c))))<br>&nbsp; <br>&nbsp; (test-with-my-struct)<br>&nbsp; <br>&nbsp; )<br><br>Thanks,<br>Doug<br>