Hi Vyzo, Carl, and Grant - <br><br>after struggling with this some more, I was finally able to create a macro with multiple definitions. Below are my take-aways: <br><ul><li>use <span style="font-weight: bold;">with-syntax
</span>
over <span style="font-weight: bold;">let</span>: let allows me to create my own symbol transformations in a function - with-syntax allows the same in a macro <br></li><li>symbol
!= syntax-object: at first my transform function returns a
symbol and I couldn't create a definition - it doesn't work until I figure out I need a syntax-object and how to use <span style="font-weight: bold;">datum->syntax-object</span> to do so <br></li><li>The
way to manipulate symbol is still through string-append - this means I need to convert the type from syntax-object -> symbol -> string
-> symbol -> syntax-object... seems quite a bit of work ;) <br></li><li>use <span style="font-weight: bold;">define-for-syntax</span> rather than <span style="font-weight: bold;">define </span>to abstract the transformation
<br></li><li>syntax-case affords more control... syntax-rules use might be limited </li></ul>My head still hurts but I definitely learned something here - again thanks for the help! ;) <br><br>yinso <br><br><br><br><div><span class="gmail_quote">
On 4/13/07, <b class="gmail_sendername">Dimitris Vyzovitis</b> <<a href="mailto:vyzo@media.mit.edu">vyzo@media.mit.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;">
On Fri, 13 Apr 2007, Yin-So Chen wrote:<br><br>> Hi all -<br>><br>> I have a couple of related questions about define-syntax - basically I am<br>> wondering how some language facilities such as struct or classes are done as
<br>> macros:<br>><br>> 1. how can define-syntax create multiple forms/definitions - I found<br>> the entry on <a href="http://community.schemewiki.org/?scheme-faq-macros">http://community.schemewiki.org/?scheme-faq-macros
</a> but<br>> unable to extrapolate from there to creating of something similar to a<br>> define-struct<br>> 2. how to generate names based on the struct/class name into the<br>> definitions - seems like there needs to be ways of inserting results of a
<br>> function call into define-syntax?<br><br>If you are trying to make a define-struct like macro with standard<br>naming conventions, check generate-struct-declaration (lives in struct.ss<br>of the syntax collection).
<br><br>For more general, arbitrary symbol injections, syntax-object->datum and<br>dautm->syntax-object are your friends.<br>Break down the syntax with syntax-case, ->datum, manipulate to make<br>your identifiers, ->syntax.
<br><br>To put the result of function calls in the transformer environment back<br>into generated syntax, use quasisyntax/unsyntax/unsyntax-splicing (#` #,<br>#,@)<br><br>-- vyzo<br><br></blockquote></div><br><br clear="all">
<br>-- <br><a href="http://www.yinsochen.com">http://www.yinsochen.com</a><br>...continuous learning...