<div>Hi all - </div><div><br></div><div>I have now implemented the pattern matching/transforming algorithm of a macro expander (no hygiene yet) for a single macro expansion call.  The next step is to figure out how to apply the macro expanders recursively &quot;in order&quot;.  </div>
<div><br></div><div>For example, let&#39;s say we want to expand the following: </div><div><br></div><blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;"><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">(or (and #t #t) #f) </font></div>
</blockquote><div><br></div><div>Should it be expanded via the head position first (i.e. finish expanding or before expanding and) </div><div><div><br></div></div><blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;">
<div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">(or (and #t #t) #f) </font></div></div><div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace"><br></font></div></div>
<div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">=&gt; (let ((g (and #t #t))) (if g g #f)) </font></div></div><div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace"><br>
</font></div></div><div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">=&gt; ((lambda (g) (if g g #f)) (and #t #t)) </font></div></div><div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace"><br>
</font></div></div><div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">=&gt; ((lambda (g) (if g g #f)) (let ((h #t)) (if h #t #f))) </font></div></div><div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace"><br>
</font></div></div><div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">=&gt; ((lambda (g) (if g g #f)) ((lambda (h) (if h #t #t)) #t)) </font></div></div></blockquote><div><br></div><div>Or should the arguments be expanded before the head position expanding again? (expanding or and and together): </div>
<div><br></div><blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;"><div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">(or (and #t #t) #f) </font></div>
</div><div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace"><br></font></div></div><div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">=&gt; (let ((g (and #t #t))) (if g g #f)) </font></div>
</div><div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace"><br></font></div></div><div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">=&gt; (let ((g (let ((h #t)) (if h #t #f)))) (if g g #f)) </font></div>
</div><div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace"><br></font></div></div><div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">=&gt; ((lambda (g) (if g g #f)) (let ((h #t)) (if h #t #f))) </font></div>
</div><div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace"><br></font></div></div><div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">=&gt; ((lambda (g) (if g g #f)) ((lambda (h) (if h #t #f)) #t)) </font></div>
</div></blockquote><div><br></div><div>Does (and should) it matter either way?  Any inputs are appreciated.  Thanks,</div><div>yc</div><br><div class="gmail_quote">On Sun, Dec 5, 2010 at 11:21 AM, YC <span dir="ltr">&lt;<a href="mailto:yinso.chen@gmail.com">yinso.chen@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><br><br><div class="gmail_quote"><div class="im">On Sun, Dec 5, 2010 at 10:47 AM, Jon Rafkind <span dir="ltr">&lt;<a href="mailto:rafkind@cs.utah.edu" target="_blank">rafkind@cs.utah.edu</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


  
    
  
  <div text="#000000" bgcolor="#ffffff"><div><br></div>
    Attached is a simple macro expander (but not hygienic) that follows
    the algorithm laid out in the paper &quot;Macro by Example&quot; by Wand and
    others. Its written in python but the code follows the paper
    reasonably close so maybe you can understand it. The paper is on the
    acm digital library if you can load it (but for some reason its not
    loading for me right now, so here is a google search link to it).<br>
    <br>
<a href="http://www.google.com/url?sa=t&amp;source=web&amp;cd=1&amp;ved=0CBgQFjAA&amp;url=http%3A%2F%2Fportal.acm.org%2Fcitation.cfm%3Fid%3D41632&amp;ei=u9z7TPWCMY76sAO__MD3DQ&amp;usg=AFQjCNGnasAUQsGpiVJik29wZRUwHBnz1w" target="_blank">http://www.google.com/url?sa=t&amp;source=web&amp;cd=1&amp;ved=0CBgQFjAA&amp;url=http%3A%2F%2Fportal.acm.org%2Fcitation.cfm%3Fid%3D41632&amp;ei=u9z7TPWCMY76sAO__MD3DQ&amp;usg=AFQjCNGnasAUQsGpiVJik29wZRUwHBnz1w</a><br>


    <br></div></blockquote><div><br></div></div><div>Thanks Jon for the example code and the links to paper.  I don&#39;t have access to ACM, but the python code looks quite understandable, even though I am not too familiar with Python.  I will study the code to see what I can glean from it. </div>

<div><br></div><div><br></div></div></blockquote></div>