<br><br><div><span class="gmail_quote">On 10/18/07, <b class="gmail_sendername">Grant Rettke</b> <<a href="mailto:grettke@acm.org">grettke@acm.org</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 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> (if (null? args) x<br> (set! field-X (car args))))
<br><br>Classes can look like this now:<br><br>(define service-call%<br> (class* object% ()<br> (property customer-name)<br> (property customer-id)<br> (property call-type-code)<br> (property date-of-call-string)
<br> (super-new)))<br><br>I'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> (class* object% ()<br> (property customer-name customer-id call-type-code date-of-call-string)<br> (super-new)))<br><br>But I don'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've spent my weekends pestering Jens on similar topics. In response to a similar question he reccomended
<br><br>"Two articles to start with are:<br><br> Writing hygienic macros in Scheme with syntax-case.<br> Kent Dybvig<br> <<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>><br><br>And in the PLT Scheme case:<br><br> Composable and Compilable macros<br> Matthew Flatt<br> <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's thesis is also<br>worth a read. And I believe Ryan's thesis will be about<br>macros too."<br><br>Of these, I'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> ((pattern ...)<br> (begin (display #'(syntax stuff))(newline) #'(the macro expansion))))<br><br>When DrScheme displays the syntax object she will give you access to all its properties.
<br><br><br> </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>