<br><br><div><span class="gmail_quote">On 10/18/07, <b class="gmail_sendername">Grant Rettke</b> &lt;<a href="mailto:grettke@acm.org">grettke@acm.org</a>&gt; 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 folks,<br><br>I wanted to start by writing a macro to declare (MzLib) class<br>properties. A class property feature looks like:<br><br>(field (field-X null))<br>(define/public (X . args)<br>&nbsp;&nbsp;&nbsp;&nbsp;(if (null? args) x<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(set! field-X (car args))))
<br><br>Classes can look like this now:<br><br>(define service-call%<br>&nbsp;&nbsp;(class* object% ()<br>&nbsp;&nbsp;&nbsp;&nbsp;(property customer-name)<br>&nbsp;&nbsp;&nbsp;&nbsp;(property customer-id)<br>&nbsp;&nbsp;&nbsp;&nbsp;(property call-type-code)<br>&nbsp;&nbsp;&nbsp;&nbsp;(property date-of-call-string)
<br>&nbsp;&nbsp;&nbsp;&nbsp;(super-new)))<br><br>I&#39;m only learning about macros. That said, if you have a look at the<br>macro (at the end), is there anything obviously wrong about it? right<br>about it? any comments or advice?<br><br>The next step is that I would like to be able to do this:
<br><br>(define service-call%<br>&nbsp;&nbsp;(class* object% ()<br>&nbsp;&nbsp;&nbsp;&nbsp;(property customer-name customer-id call-type-code date-of-call-string)<br>&nbsp;&nbsp;&nbsp;&nbsp;(super-new)))<br><br>But I don&#39;t understand how to do that. Any ideas?<br><br>
For reading I am sticking with TSPL3 and the Help Desk. Anywhere else<br>I should look?</blockquote><div><br>Recently, I&#39;ve spent my weekends pestering Jens on similar topics.&nbsp; In response to a similar question he reccomended
<br><br>&quot;Two articles to start with are:<br><br> &nbsp; Writing hygienic macros in Scheme with syntax-case.<br> &nbsp; Kent Dybvig<br> &nbsp; &lt;<a onclick="return top.js.OpenExtLink(window,event,this)" href="http://www.cs.indiana.edu/%7Edyb/pubs/tr356.pdf" target="_blank">
http://www.cs.indiana.edu/~dyb/pubs/tr356.pdf</a>&gt;<br><br>And in the PLT Scheme case:<br><br> &nbsp; Composable and Compilable macros<br> &nbsp; Matthew Flatt<br> &nbsp; <a onclick="return top.js.OpenExtLink(window,event,this)" href="http://www.cs.utah.edu/plt/publications/macromod.pdf" target="_blank">
http://www.cs.utah.edu/plt/publications/macromod.pdf</a><br><br>If I recall correctly Oscar Waddell&#39;s thesis is also<br>worth a read. And I believe Ryan&#39;s thesis will be about<br>macros too.&quot;<br><br>Of these, I&#39;ve only had time to seriously look at the first report by Dybvig, and I like it, as it goes into much more depth than TSPL.
<br><br>As far as debugging goes, I have found that the following to be useful<br>(syntax-case foo ()<br>&nbsp; ((pattern ...)<br>&nbsp;&nbsp; (begin (display #&#39;(syntax stuff))(newline) #&#39;(the macro expansion))))<br><br>When DrScheme displays the syntax object she will give you access to all its properties. 
<br><br><br>&nbsp;</div><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Best wishes,<br><br>Grant Rettke<br><br></blockquote></div><br>