<?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"
	>
<channel>
	<title>Comments on: Macro trial balloons</title>
	<atom:link href="http://4.flowsnake.org/archives/66/feed" rel="self" type="application/rss+xml" />
	<link>http://4.flowsnake.org/archives/66</link>
	<description>A Pythoneer's adventures with Chicken Scheme. ^_^ And more.</description>
	<pubDate>Wed, 07 Jan 2009 00:41:27 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.5</generator>
		<item>
		<title>By: Graham Fawcett</title>
		<link>http://4.flowsnake.org/archives/66#comment-110</link>
		<dc:creator>Graham Fawcett</dc:creator>
		<pubDate>Sat, 16 Feb 2008 21:45:01 +0000</pubDate>
		<guid isPermaLink="false">http://4.flowsnake.org/archives/66#comment-110</guid>
		<description>Sure, absolutely.</description>
		<content:encoded><![CDATA[<p>Sure, absolutely.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Hans Nowak</title>
		<link>http://4.flowsnake.org/archives/66#comment-108</link>
		<dc:creator>Hans Nowak</dc:creator>
		<pubDate>Sat, 16 Feb 2008 13:30:27 +0000</pubDate>
		<guid isPermaLink="false">http://4.flowsnake.org/archives/66#comment-108</guid>
		<description>Thanks, Graham. With your permission, I will use the new definition of inc! in the s1 code.</description>
		<content:encoded><![CDATA[<p>Thanks, Graham. With your permission, I will use the new definition of inc! in the s1 code.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Graham Fawcett</title>
		<link>http://4.flowsnake.org/archives/66#comment-105</link>
		<dc:creator>Graham Fawcett</dc:creator>
		<pubDate>Sat, 16 Feb 2008 05:02:42 +0000</pubDate>
		<guid isPermaLink="false">http://4.flowsnake.org/archives/66#comment-105</guid>
		<description>You might also be interested in using pattern-matching in your macros. It's overkill for this example, but it's helpful when the arglist for your macro is complicated:

(define-macro (inc! var . vals)
  (match vals
    (() `(set! ,var (+ 1 ,var)))
    (nums `(set! ,var (+ ,var ,@nums)))))

The first clause matches when the vals list is emtpy, and the second clause ('nums') is an 'otherwise' clause -- nums matches the entire vals object (in this case, it must be a list of 1 or more elements). 
 
The match system is built into Chicken; search for 'pattern matching' in the manual. Very cool stuff. :-)</description>
		<content:encoded><![CDATA[<p>You might also be interested in using pattern-matching in your macros. It's overkill for this example, but it's helpful when the arglist for your macro is complicated:</p>
<p>(define-macro (inc! var . vals)<br />
  (match vals<br />
    (() `(set! ,var (+ 1 ,var)))<br />
    (nums `(set! ,var (+ ,var ,@nums)))))</p>
<p>The first clause matches when the vals list is emtpy, and the second clause ('nums') is an 'otherwise' clause -- nums matches the entire vals object (in this case, it must be a list of 1 or more elements). </p>
<p>The match system is built into Chicken; search for 'pattern matching' in the manual. Very cool stuff. :-)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Graham Fawcett</title>
		<link>http://4.flowsnake.org/archives/66#comment-104</link>
		<dc:creator>Graham Fawcett</dc:creator>
		<pubDate>Sat, 16 Feb 2008 04:54:08 +0000</pubDate>
		<guid isPermaLink="false">http://4.flowsnake.org/archives/66#comment-104</guid>
		<description>You're working too hard for that inc! macro, I think. What about this:

(define-macro (inc! var . vals)
  `(set! ,var (+ ,var ,@vals)))

Wait, I see you want a case for an empty val-list. This would work, 

(define-macro (inc! var . vals)
  `(set! ,var (+ ,var
                 ,@(if (null? vals)
                       '(1) vals))))

The gensym stuff is important when you want to avoid a name collision, but in your case, there's no need for an intermediate variable, so no gensyms are required.</description>
		<content:encoded><![CDATA[<p>You're working too hard for that inc! macro, I think. What about this:</p>
<p>(define-macro (inc! var . vals)<br />
  `(set! ,var (+ ,var ,@vals)))</p>
<p>Wait, I see you want a case for an empty val-list. This would work, </p>
<p>(define-macro (inc! var . vals)<br />
  `(set! ,var (+ ,var<br />
                 ,@(if (null? vals)<br />
                       '(1) vals))))</p>
<p>The gensym stuff is important when you want to avoid a name collision, but in your case, there's no need for an intermediate variable, so no gensyms are required.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
