title: How do I write anaphoric macros in portable scheme?
body: <p>I'm exploring Scheme macros, but I've been unable to find a portable way of writing anaphoric macros.</p>
  
  <p>I'm trying to write an <code>each-it</code> macro, such that this code:</p>
  
  <pre><code>(each-it (list 1 2 3)
    (display it))
  </code></pre>
  
  <p>Expands to this:</p>
  
  <pre><code>(for-each (lambda (it)
              (display it))
            (list 1 2 3))
  </code></pre>
  
  <p>I've written a macro with <code>syntax-rules</code>, but this gives me an error about an undefined identifier when I try to use it.</p>
  
  <pre><code>(define-syntax each-it
    (syntax-rules ()
      ((each-it lst body)
       (for-each (lambda (it) body)
                 lst))))
  </code></pre>
  
  <p><a href="https://stackoverflow.com/a/20055079/509706">This SO question</a> mentions <code>define-syntax-parameter</code>, which seems to be Racket only. <a href="http://blog.racket-lang.org/2008/02/dirty-looking-hygiene.html" rel="nofollow noreferrer">This blog post</a> gives some Scheme code samples, but the code samples don't run in DrRacket in <code>R5RS</code> mode (I think it's the square brackets?).</p>
  
  <p><a href="http://people.csail.mit.edu/jaffer/r4rs_12.html#SEC77" rel="nofollow noreferrer">R4RS has an interesting macro appendix</a> but it is not present in R5RS and I don't know if I can depend on it.</p>
  
  <p>Can I write my <code>each-it</code> macro in a completely portable way? If not, what are the most widely available macro system features for writing my macro?</p>