<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Blog of Anders Rune Jensen &#187; lisp</title>
	<atom:link href="http://people.iola.dk/arj/category/lisp/feed/" rel="self" type="application/rss+xml" />
	<link>http://people.iola.dk/arj</link>
	<description>metalinguistic musings and other related ramblings</description>
	<lastBuildDate>Fri, 18 Nov 2011 19:13:49 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2</generator>
		<item>
		<title>Finished reading Practical Common Lisp</title>
		<link>http://people.iola.dk/arj/2007/11/23/finished-reading-practical-common-lisp/</link>
		<comments>http://people.iola.dk/arj/2007/11/23/finished-reading-practical-common-lisp/#comments</comments>
		<pubDate>Fri, 23 Nov 2007 02:10:20 +0000</pubDate>
		<dc:creator>Anders Rune Jensen</dc:creator>
				<category><![CDATA[.net]]></category>
		<category><![CDATA[boo]]></category>
		<category><![CDATA[Books]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[lisp]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://people.iola.dk/arj/2007/11/23/finished-reading-practical-common-lisp/</guid>
		<description><![CDATA[<p>Finally got through the mighty <a href="http://www.gigamonkeys.com/book/">Practical Common Lisp</a> tome. The style of the book is written in a nice mix of theory and practice (with relevant and good examples). My friend Lau asked me why on earth I would want to read a book on Lisp? A fair question since Lisp is really old, actually measured in computer time it might even be called ancient. But I had two main motivations for reading the book, to become a <a href="http://www.catb.org/~esr/faqs/hacker-howto.html">better programmer</a> and secondly to better understand new language features introduced in languages like <a href="http://boo.codehaus.org/">Boo</a> and C#. Just look at the new <a href="http://msdn2.microsoft.com/en-us/netframework/aa904594.aspx">LINQ</a> features in C# 3.0 and specifically this <a href="http://blogs.msdn.com/charlie/archive/2007/01/26/anders-hejlsberg-on-linq-and-functional-programming.aspx">video</a>.</p>
<p>I wholeheartedly recommend this book to anyone interesting in a good programming book.</p>
]]></description>
		<wfw:commentRss>http://people.iola.dk/arj/2007/11/23/finished-reading-practical-common-lisp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The power of lisp part 2</title>
		<link>http://people.iola.dk/arj/2007/10/24/the-power-of-lisp-part-2/</link>
		<comments>http://people.iola.dk/arj/2007/10/24/the-power-of-lisp-part-2/#comments</comments>
		<pubDate>Wed, 24 Oct 2007 01:38:07 +0000</pubDate>
		<dc:creator>Anders Rune Jensen</dc:creator>
				<category><![CDATA[boo]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[lisp]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://people.iola.dk/arj/2007/10/24/the-power-of-lisp-part-2/</guid>
		<description><![CDATA[<p>As mentioned earlier, lisp is incredible at abstracting away small everyday stuff you write over and over. A good example is this way one has to define a local variable in order to make variables sucked into a delegates from the surroundings static in C#. As mentioned briefly in <a href="http://people.iola.dk/arj/2007/10/24/the-power-of-lisp-part-1/">this blog post</a>, one needs to change the loop to read like the following code for it to print 0 to 9 instead of 10 times 9:</p>
<pre class="prettyprint">foreach (int i in numbers) {

        int j = i;

        l.Add(delegate() { System.Console.WriteLine(j); };
}</pre>
<p>In lisp one would see that this is a pattern and simply abstract it away like <a href="http://people.iola.dk/anders/example.lisp">this</a>. As one can see, the macro static-loop is more or less exactly the same as the pattern which luckily made it quite easy to write.</p>
<pre class="prettyprint">
(defmacro static-loop ((i container) &amp;body body)
 (with-gensyms (j)
  `(loop for ,j in ,container do
    (let ((,i ,j))
     ,@body))))</pre>
<p>The only small trick is the with-gensyms macro which prevents <a href="http://www.joelonsoftware.com/articles/LeakyAbstractions.html">leaking</a> the temporary variable j into the scope of where it will be substituted into. So in that regard the macro is even nicer than rolling your own temp variable hack <img src='http://people.iola.dk/arj/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>For reference the <a href="http://people.iola.dk/anders/example.py.txt">python example</a> works the same way, but allows one to use the lambda function to redefine variables, although one must note that the static-loop solution is more general in that it will make the loop variable local for the whole scope and not just for one lambda function. Funny thing is that I had originally written it like <a href="http://people.iola.dk/anders/example-faulty.py.txt">this</a>, which actually worked, although that means that the closure binding is not only by reference but by name.</p>
<p>I tried writing the macro in boo but I failed. Apparently their macro support is still quite new and there&#8217;s close to no examples to draw inspiration from. If anyone could help me out with the solution please mail it to me or even better add it as a comment.</p>
]]></description>
		<wfw:commentRss>http://people.iola.dk/arj/2007/10/24/the-power-of-lisp-part-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

