<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	>
<channel>
	<title>Comments on: Common Lisp vs. Scheme macros</title>
	<atom:link href="http://eli.thegreenplace.net/2007/09/16/common-lisp-vs-scheme-macros/feed/" rel="self" type="application/rss+xml" />
	<link>http://eli.thegreenplace.net/2007/09/16/common-lisp-vs-scheme-macros/</link>
	<description>Eli Bendersky's personal website</description>
	<pubDate>Thu, 08 Jan 2009 01:09:55 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: John Connors</title>
		<link>http://eli.thegreenplace.net/2007/09/16/common-lisp-vs-scheme-macros/comment-page-1/#comment-72948</link>
		<dc:creator>John Connors</dc:creator>
		<pubDate>Fri, 21 Sep 2007 13:24:41 +0000</pubDate>
		<guid isPermaLink="false">http://eli.thegreenplace.net/2007/09/16/common-lisp-vs-scheme-macros/#comment-72948</guid>
		<description>You might be interested in this: Scheme macros for Common Lisp.

http://www.ccs.neu.edu/home/dorai/mbe/mbe-lsp.html</description>
		<content:encoded><![CDATA[<p>You might be interested in this: Scheme macros for Common Lisp.</p>
<p><a href="http://www.ccs.neu.edu/home/dorai/mbe/mbe-lsp.html" rel="nofollow">http://www.ccs.neu.edu/home/dorai/mbe/mbe-lsp.html</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jens Axel Søgaard</title>
		<link>http://eli.thegreenplace.net/2007/09/16/common-lisp-vs-scheme-macros/comment-page-1/#comment-72688</link>
		<dc:creator>Jens Axel Søgaard</dc:creator>
		<pubDate>Wed, 19 Sep 2007 20:01:24 +0000</pubDate>
		<guid isPermaLink="false">http://eli.thegreenplace.net/2007/09/16/common-lisp-vs-scheme-macros/#comment-72688</guid>
		<description>Hi Eli.

Here is the macro in the syntax-case system.

(require (planet "math.ss" ("soegaard" "math.plt" 1 2)))

(define-syntax (do-primes stx)
  (syntax-case stx ()
    [(do-primes var start end body ...)
     #'(let ([ending-value end])
         (do ((var (next-prime start) (next-prime (+ 1 var))))
           [(&#62; var ending-value)]
           body ...))]))

Example:

&#62; (do-primes p 2 17
           (display p)
           (newline))
3
5
7
11
13
17</description>
		<content:encoded><![CDATA[<p>Hi Eli.</p>
<p>Here is the macro in the syntax-case system.</p>
<p>(require (planet &#8220;math.ss&#8221; (&#8221;soegaard&#8221; &#8220;math.plt&#8221; 1 2)))</p>
<p>(define-syntax (do-primes stx)<br />
  (syntax-case stx ()<br />
    [(do-primes var start end body ...)<br />
     #'(let ([ending-value end])<br />
         (do ((var (next-prime start) (next-prime (+ 1 var))))<br />
           [(&gt; var ending-value)]<br />
           body &#8230;))]))</p>
<p>Example:</p>
<p>&gt; (do-primes p 2 17<br />
           (display p)<br />
           (newline))<br />
3<br />
5<br />
7<br />
11<br />
13<br />
17</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrew Gwozdziewycz</title>
		<link>http://eli.thegreenplace.net/2007/09/16/common-lisp-vs-scheme-macros/comment-page-1/#comment-72338</link>
		<dc:creator>Andrew Gwozdziewycz</dc:creator>
		<pubDate>Mon, 17 Sep 2007 12:12:35 +0000</pubDate>
		<guid isPermaLink="false">http://eli.thegreenplace.net/2007/09/16/common-lisp-vs-scheme-macros/#comment-72338</guid>
		<description>Scheme implementations commonly support other types of macros that allow you to break hygiene for a specific instance. syntax-case macros are hygienic and use the syntax-rules language but they introduce a few forms such as datum-&#62;syntax and syntax-&#62;datum which can be used to break hygiene. Explicit renaming macros, found in scheme48, allow you to write defmacro style macros while rebinding the forms you use to new names to keep things hygienic. MIT scheme supports syntaxtic closures which allows a macro to use the bindings present at the time of the macros definition, because it creates a closure with them enclosed. These are also defmacro like. However, it is of course the case that different schemes implement different systems, but I dont' think it's a case where a system cannot be ported to another, it just adds a bunch of extra work. Good luck with choosing!</description>
		<content:encoded><![CDATA[<p>Scheme implementations commonly support other types of macros that allow you to break hygiene for a specific instance. syntax-case macros are hygienic and use the syntax-rules language but they introduce a few forms such as datum-&gt;syntax and syntax-&gt;datum which can be used to break hygiene. Explicit renaming macros, found in scheme48, allow you to write defmacro style macros while rebinding the forms you use to new names to keep things hygienic. MIT scheme supports syntaxtic closures which allows a macro to use the bindings present at the time of the macros definition, because it creates a closure with them enclosed. These are also defmacro like. However, it is of course the case that different schemes implement different systems, but I dont&#8217; think it&#8217;s a case where a system cannot be ported to another, it just adds a bunch of extra work. Good luck with choosing!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Barry Perryman</title>
		<link>http://eli.thegreenplace.net/2007/09/16/common-lisp-vs-scheme-macros/comment-page-1/#comment-72334</link>
		<dc:creator>Barry Perryman</dc:creator>
		<pubDate>Mon, 17 Sep 2007 11:45:37 +0000</pubDate>
		<guid isPermaLink="false">http://eli.thegreenplace.net/2007/09/16/common-lisp-vs-scheme-macros/#comment-72334</guid>
		<description>Paul Grahams excellent On Lisp book, which you can get in PDF form from his web site, has a good chunk of the book devoted to the darker corners of macros.

One of the type of macros he develops is an Anaphoric macro for things like IF. So, from memory, the CL code would be something like

(defmacro aif (test true-branch &#38;optional false-branch)
  `(let ((it ,test))
     (if it
        ,true-branch
        ,false-branch)))

Which enables you to write code like this:

(aif (position #\: my-string)
    (subseq my-string 0 it)
    "")

where 'it' refers to the value that the test returned. This is a macro for the following type of pattern, shown here in the following similar code:

(let ((pos (position #\" my-string)))
  (if pos
    (subseq my-string 0 pos)
    ""))

AFAIK this isn't possible with Hygenic macros, because they see the 'it' defined in the 'let' expression as something that needs to be hygenic, and thus you can't refer to it in your usage of aif.</description>
		<content:encoded><![CDATA[<p>Paul Grahams excellent On Lisp book, which you can get in PDF form from his web site, has a good chunk of the book devoted to the darker corners of macros.</p>
<p>One of the type of macros he develops is an Anaphoric macro for things like IF. So, from memory, the CL code would be something like</p>
<p>(defmacro aif (test true-branch &amp;optional false-branch)<br />
  `(let ((it ,test))<br />
     (if it<br />
        ,true-branch<br />
        ,false-branch)))</p>
<p>Which enables you to write code like this:</p>
<p>(aif (position #\: my-string)<br />
    (subseq my-string 0 it)<br />
    &#8220;&#8221;)</p>
<p>where &#8216;it&#8217; refers to the value that the test returned. This is a macro for the following type of pattern, shown here in the following similar code:</p>
<p>(let ((pos (position #\&#8221; my-string)))<br />
  (if pos<br />
    (subseq my-string 0 pos)<br />
    &#8220;&#8221;))</p>
<p>AFAIK this isn&#8217;t possible with Hygenic macros, because they see the &#8216;it&#8217; defined in the &#8216;let&#8217; expression as something that needs to be hygenic, and thus you can&#8217;t refer to it in your usage of aif.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
