<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>(defun ugly-lisp-code? () ())</title>
	<atom:link href="http://uglylispcode.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://uglylispcode.wordpress.com</link>
	<description>lisp cargo cultist trying to lamda</description>
	<lastBuildDate>Mon, 27 Jul 2009 04:41:02 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='uglylispcode.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>(defun ugly-lisp-code? () ())</title>
		<link>http://uglylispcode.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://uglylispcode.wordpress.com/osd.xml" title="(defun ugly-lisp-code? () ())" />
	<atom:link rel='hub' href='http://uglylispcode.wordpress.com/?pushpress=hub'/>
		<item>
		<title>ugly-lisp-code compendium</title>
		<link>http://uglylispcode.wordpress.com/2009/07/26/ugly-lisp-code-compendium/</link>
		<comments>http://uglylispcode.wordpress.com/2009/07/26/ugly-lisp-code-compendium/#comments</comments>
		<pubDate>Mon, 27 Jul 2009 04:41:02 +0000</pubDate>
		<dc:creator>gutzofter</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://uglylispcode.wordpress.com/?p=204</guid>
		<description><![CDATA[It has been some time since I&#8217;ve posted on this blog. This blog is going into hiatus for now! A more current blog is in the works. This blog will explore ideas in many languages and systems. Hopefully you will be able to use these ideas below to learn something or even take them to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=uglylispcode.wordpress.com&amp;blog=3958143&amp;post=204&amp;subd=uglylispcode&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>It has been some time since I&#8217;ve posted on this blog. This blog is going into hiatus for now!</p>
<p><a href="http://uglycode.wordpress.com">A more current blog is in the works</a>. This blog will explore ideas in many languages and systems.</p>
<p>Hopefully you will be able to use these ideas below to learn something or even take them to the next level.</p>
<p>Feel free to leave me some comments. Thank You!</p>
<h3>Exploring an extension to a basic unit testing framework. The extension encapsulates the idea of unit-tests wrapped by a test-fixture.</h3>
<ul>
<li><a href="http://uglylispcode.wordpress.com/2008/07/20/dog-fooding-a-dsl-creating-an-extension-to-lisp-unit/">Dog-fooding a Domain Specific Language (DSL); creating an extension to lisp-unit</a></li>
<li><a href="http://uglylispcode.wordpress.com/2008/11/18/update-to-test-fixture/">Update to test-fixture</a></li>
</ul>
<h3></h3>
<h3>Exploring a lightweight object-oriented type in Common Lisp.</h3>
<ul>
<li><a href="http://uglylispcode.wordpress.com/2008/10/31/an-object-in-lisp-part-1/">An Object in Lisp. Part 1</a></li>
<li><a href="http://uglylispcode.wordpress.com/2008/11/18/an-object-in-lisp-part-2/">An Object in Lisp. Part 2</a></li>
<li><a href="http://uglylispcode.wordpress.com/2008/11/27/an-object-in-lisp-part-2-addendum/">An Object in Lisp. Part 2 Addendum</a></li>
<li><a href="http://uglylispcode.wordpress.com/2008/11/30/an-object-in-lisp-part-3/">An Object in Lisp. Part 3</a></li>
<li><a href="http://uglylispcode.wordpress.com/2008/12/03/an-object-in-lisp-part-4/">An Object in Lisp. Part 4</a></li>
<li><a href="http://uglylispcode.wordpress.com/2008/12/18/an-object-in-lisp-part-5/">An Object in Lisp. Part 5</a></li>
<li><a href="http://uglylispcode.wordpress.com/2009/01/02/an-object-in-lisp-part-6/">An Object in Lisp. Part 6</a></li>
</ul>
<h3></h3>
<h3>Exploration of an event driven system in Common Lisp.</h3>
<ul>
<li><a href="http://uglylispcode.wordpress.com/2008/12/03/event-driven-architecture-programming-in-lisp-part-1/">Event Driven Architecture Programming in Lisp Part 1</a></li>
<li><a href="http://uglylispcode.wordpress.com/2008/12/04/event-driven-architecture-programming-in-lisp-part-2/">Event Driven Architecture Programming in Lisp Part 2</a></li>
</ul>
<h3></h3>
<h3>An efficient methodology for me when working with lightweight objects.</h3>
<ul>
<li><a href="http://uglylispcode.wordpress.com/2009/01/05/object-programming-in-lisp-observation-1/">Object Programming in Lisp Observation #1</a></li>
</ul>
<h3>Tools and explorations that were used for the above projects.</h3>
<ul>
<li><a href="http://www.box.net/shared/qb6nejhact">object.zip</a></li>
<li><a href="http://www.box.net/shared/cnyu26js10">lisp-unit-with-fixture</a></li>
<li><a href="http://www.box.net/shared/uaficu3scf">coverage-runner</a></li>
<li><a href="http://www.box.net/shared/32581yufpv">presenter-first</a></li>
<li><a href="http://www.box.net/shared/86lr6l64rv">mock</a></li>
</ul>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/uglylispcode.wordpress.com/204/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/uglylispcode.wordpress.com/204/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/uglylispcode.wordpress.com/204/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/uglylispcode.wordpress.com/204/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/uglylispcode.wordpress.com/204/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/uglylispcode.wordpress.com/204/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/uglylispcode.wordpress.com/204/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/uglylispcode.wordpress.com/204/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/uglylispcode.wordpress.com/204/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/uglylispcode.wordpress.com/204/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/uglylispcode.wordpress.com/204/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/uglylispcode.wordpress.com/204/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/uglylispcode.wordpress.com/204/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/uglylispcode.wordpress.com/204/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=uglylispcode.wordpress.com&amp;blog=3958143&amp;post=204&amp;subd=uglylispcode&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://uglylispcode.wordpress.com/2009/07/26/ugly-lisp-code-compendium/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0b46bfc49b7ec609136bf30d273f80f7?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">gutzofter</media:title>
		</media:content>
	</item>
		<item>
		<title>Rules Engine or Event Collaboration</title>
		<link>http://uglylispcode.wordpress.com/2009/01/09/rules-engine-or-event-collaboration/</link>
		<comments>http://uglylispcode.wordpress.com/2009/01/09/rules-engine-or-event-collaboration/#comments</comments>
		<pubDate>Fri, 09 Jan 2009 09:41:12 +0000</pubDate>
		<dc:creator>gutzofter</dc:creator>
				<category><![CDATA[Domain Specific Language]]></category>
		<category><![CDATA[EDA]]></category>
		<category><![CDATA[Event Collaboration]]></category>
		<category><![CDATA[Event Driven Programming]]></category>
		<category><![CDATA[Production System]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Rules Engine]]></category>

		<guid isPermaLink="false">http://uglylispcode.wordpress.com/?p=184</guid>
		<description><![CDATA[Models of Computation Some examples of models of computation include General Recursive Functions, Turing Machines, Lambda Calculus, Finite State Machines, and Production Systems. These are only some models of computation. Martin Fowler has a pretty good post on rules engines (production system). &#8220;&#8230; providing an alternative computational model.&#8221; Wikipedia&#8217;s definition is &#8220;A model of computation [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=uglylispcode.wordpress.com&amp;blog=3958143&amp;post=184&amp;subd=uglylispcode&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><strong>Models of Computation</strong></p>
<p>Some examples of models of computation include General Recursive Functions, Turing Machines, Lambda Calculus, Finite State Machines, and Production Systems. These are only some models of computation.</p>
<p>Martin Fowler has a pretty good post on rules engines (production system).<em> <a href="http://martinfowler.com/bliki/RulesEngine.html">&#8220;&#8230; providing an alternative computational model.&#8221;</a></em></p>
<p>Wikipedia&#8217;s definition is <em>&#8220;A model of computation is the definition of the set of allowable operations used in computation and their respective costs.&#8221;</em> I myself like the definition provided by <a href="http://mitpress.mit.edu/books/FLAOH/cbnhtml/home.html">&#8220;The Computational Beauty of Nature&#8221;</a> [p27]. <em>&#8220;&#8230; a model of computation describes how to build recipes or, if you like , a recipe for recipes.&#8221;</em></p>
<p>Both definitions seem to define two different things. The first definition describes programming languages. The second describes meta programming. These two definitions are not mutually exclusive. All programming languages have some form of meta programming. Just some languages have more powerful meta programming facilities.</p>
<p>In Common Lisp the most common way for the usage of meta programming is through the use of <strong>defmacro</strong>. <a href="http://bc.tech.coop/blog/050704.html">Bill Clementson&#8217;s Blog post</a> covers <a href="http://lispm.dyndns.org/news?ID=NEWS-2005-07-08-1">Joswig&#8217;s</a> use of an embedded DSL in Lisp. Guess what allows him to make such a compact DSL? <strong>defmacro </strong>of course. Another nice Joswig post on <a href="http://groups.google.com/group/comp.lang.lisp/msg/8ff674d727c8c4a0">comp.lang.lisp</a> goes through an iterative cycle of design using defmacro.</p>
<p><strong><span id="more-184"></span>Benefits and Liabilities of Using The Model</strong></p>
<p>In Fowler&#8217;s post he spends about half of it talking about the liabilities of a <a href="http://martinfowler.com/bliki/RulesEngine.html">RulesEngine</a>.The liabilities that he describes are not so dissimilar to the liabilities associated to using <a href="http://martinfowler.com/eaaDev/EventCollaboration.html">Event Collaboration</a>. The benefits are also similar.  At this time I believe it is due to the nature of rules engine and event collaboration are based on graphs. Research on <a href="http://en.wikipedia.org/wiki/Rete_algorithm">RETE</a> to find the similarites, I think is in order.</p>
<p><strong>+Weak Coupling and High Cohesion</strong>. Allows rules and events to evolve without making changes all over system. Does not need to have dependencies between rules or events in order to execute.</p>
<p><strong>+Asynchronous Communications</strong>. Any rule or event can be executed at any time or in any order.</p>
<p><strong>-No Implicit Dependencies</strong>. It is hard to debug due to complex interactions with loose coupling.</p>
<p><strong>-Duplicated Data and Code</strong>. Rules and events can have the proerty of subsumption. In other words more specific rules or events can be taken over by more general rules or events.</p>
<p><strong>Overcoming Liabilities</strong></p>
<p><span style="text-decoration:underline;">Comments in this section is welcome</span><strong><br />
</strong></p>
<p>1. Limit set of rules and events.</p>
<p>2. Reduce cyclic triggering of rules and events</p>
<p>3. Testing</p>
<p>4. Tools</p>
<p>5. Utilization of system as soon as possible.</p>
<p>6. Abstraction.</p>
<p>If you liked this you might like this:</p>
<p><a title="Permanent Link to Dog-fooding a Domain Specific Language (DSL); creating an extension to Lisp-Unit" rel="bookmark" href="../2008/07/20/dog-fooding-a-dsl-creating-an-extension-to-lisp-unit/">Dog-fooding a Domain Specific Language (DSL); creating an extension to Lisp-Unit</a></p>
<p>Please leave any comments, they will be appreciated.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/uglylispcode.wordpress.com/184/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/uglylispcode.wordpress.com/184/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/uglylispcode.wordpress.com/184/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/uglylispcode.wordpress.com/184/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/uglylispcode.wordpress.com/184/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/uglylispcode.wordpress.com/184/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/uglylispcode.wordpress.com/184/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/uglylispcode.wordpress.com/184/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/uglylispcode.wordpress.com/184/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/uglylispcode.wordpress.com/184/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/uglylispcode.wordpress.com/184/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/uglylispcode.wordpress.com/184/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/uglylispcode.wordpress.com/184/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/uglylispcode.wordpress.com/184/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=uglylispcode.wordpress.com&amp;blog=3958143&amp;post=184&amp;subd=uglylispcode&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://uglylispcode.wordpress.com/2009/01/09/rules-engine-or-event-collaboration/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0b46bfc49b7ec609136bf30d273f80f7?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">gutzofter</media:title>
		</media:content>
	</item>
		<item>
		<title>Object Programming in Lisp Observation #1</title>
		<link>http://uglylispcode.wordpress.com/2009/01/05/object-programming-in-lisp-observation-1/</link>
		<comments>http://uglylispcode.wordpress.com/2009/01/05/object-programming-in-lisp-observation-1/#comments</comments>
		<pubDate>Mon, 05 Jan 2009 21:23:06 +0000</pubDate>
		<dc:creator>gutzofter</dc:creator>
				<category><![CDATA[Lisp Programming]]></category>
		<category><![CDATA[OOP]]></category>
		<category><![CDATA[TDD]]></category>
		<category><![CDATA[Test Driven Development]]></category>

		<guid isPermaLink="false">http://uglylispcode.wordpress.com/?p=175</guid>
		<description><![CDATA[When developing with the object framework, I end up excreting all the side-effect-free (SEF) code from the object. Remember the reason for an object is to encapsulate state. (defun format-results (result-totals) (destructuring-bind (result-totals asserts passes errors elapses) result-totals (list (format nil "~A Total Test(s)" result-totals) (format nil "~A Assertions" asserts) (format nil "~A Passes" passes) [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=uglylispcode.wordpress.com&amp;blog=3958143&amp;post=175&amp;subd=uglylispcode&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>When developing with the object framework, I end up excreting all the side-effect-free (SEF) code from the object. Remember the reason for an object is to encapsulate state.</p>
<pre style="color:#000020;background:#f6f8ff;"><span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">defun</span> format-results <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">result-totals</span><span style="color:#308080;">)</span>
  <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">destructuring-bind</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">result-totals</span> asserts passes errors elapses<span style="color:#308080;">)</span> result-totals
    <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">list</span>
     <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">format</span> <span style="color:#7d0045;">nil</span> <span style="color:#1060b6;">"~A Total Test(s)"</span> result-totals<span style="color:#308080;">)</span>
     <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">format</span> <span style="color:#7d0045;">nil</span> <span style="color:#1060b6;">"~A Assertions"</span> asserts<span style="color:#308080;">)</span>
     <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">format</span> <span style="color:#7d0045;">nil</span> <span style="color:#1060b6;">"~A Passes"</span> passes<span style="color:#308080;">)</span>
     <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">format</span> <span style="color:#7d0045;">nil</span> <span style="color:#1060b6;">"~A Failures"</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">-</span> asserts passes<span style="color:#308080;">)</span><span style="color:#308080;">)</span>
     <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">format</span> <span style="color:#7d0045;">nil</span> <span style="color:#1060b6;">"~A Errors"</span> errors<span style="color:#308080;">)</span>
     <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">format</span> <span style="color:#7d0045;">nil</span> <span style="color:#1060b6;">"~,3F Second(s)"</span> elapses<span style="color:#308080;">)</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span>

<span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">defun</span> result-sums <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">result-totals</span><span style="color:#308080;">)</span>
  <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">loop</span> for <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">nil</span> assert pass error elapse<span style="color:#308080;">)</span> in result-totals
        summing assert into asserts
        summing pass into passes
        summing error into errors
        summing elapse into elapses
        finally
        <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">return</span>
         <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">list</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">length</span> result-totals<span style="color:#308080;">)</span> asserts passes errors elapses<span style="color:#308080;">)</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span>

<span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">defobj</span> results-model
  <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">:members</span> <span style="color:#308080;">(</span><span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">database</span> <span style="color:#7d0045;">nil</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span>
  <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">:methods</span> <span style="color:#308080;">(</span><span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">:get-result-totals</span> <span style="color:#308080;">(</span><span style="color:#308080;">)</span>
                  <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">format-results</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">result-sums</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">retrieve-totals</span> database<span style="color:#308080;">)</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span>

             <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">:connect-db</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">db</span><span style="color:#308080;">)</span>
               <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">setf</span> database db<span style="color:#308080;">)</span><span style="color:#308080;">)</span>

             <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">:insert-result-data</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">result-data</span><span style="color:#308080;">)</span>
               <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">add-result</span> database result-data<span style="color:#308080;">)</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span></pre>
<p>This method really it makes it easier to test the SEF functions. When using the object&#8217;s methods for interacting with state during tdd, you have to maintain a reference to the object. By excreting the functionality out of the object, you no longer need the reference. You just test for functionality.</p>
<pre style="color:#000020;background:#f6f8ff;"><span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">test-fixture</span>
 <span style="color:#400000;">:format-results</span>
 <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">:tests</span>
   <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">should-return-format-results-empty</span>
    <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">assert-equal</span> <span style="color:#406080;">'</span><span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">"0</span> Total Test<span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">s</span><span style="color:#308080;">)</span><span style="color:#1060b6;">" "</span><span style="color:#008c00;">0</span> Assertions<span style="color:#1060b6;">" "</span><span style="color:#008c00;">0</span> Passes<span style="color:#1060b6;">" "</span><span style="color:#008c00;">0</span> Failures<span style="color:#1060b6;">" "</span><span style="color:#008c00;">0</span> Errors"
           <span style="color:#1060b6;">"0.000 Second(s)"</span><span style="color:#308080;">)</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">format-results</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">list</span> <span style="color:#008c00;">0</span> <span style="color:#008c00;">0</span> <span style="color:#008c00;">0</span> <span style="color:#008c00;">0</span> <span style="color:#008c00;">0</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span>

<span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">test-fixture</span>
 <span style="color:#400000;">:result-sums</span>
 <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">:tests</span>
   <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">should-return-no-sums</span>
    <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">assert-equal</span> <span style="color:#406080;">'</span><span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">1</span> <span style="color:#008c00;">0</span> <span style="color:#008c00;">0</span> <span style="color:#008c00;">0</span> <span style="color:#008c00;">0</span><span style="color:#308080;">)</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">result-sums</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">list</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">list</span> <span style="color:#400000;">:no-name</span> <span style="color:#008c00;">0</span> <span style="color:#008c00;">0</span> <span style="color:#008c00;">0</span> <span style="color:#008c00;">0</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span>

   <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">should-return-sums</span>
    <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">assert-equal</span> <span style="color:#406080;">'</span><span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">2</span> <span style="color:#008c00;">1</span> <span style="color:#008c00;">1</span> <span style="color:#008c00;">1</span> <span style="color:#008000;">0.15100001</span><span style="color:#308080;">)</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">result-sums</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">list</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">list</span> <span style="color:#400000;">:t1</span> <span style="color:#008c00;">0</span> <span style="color:#008c00;">0</span> <span style="color:#008c00;">1</span> <span style="color:#008000;">0.001</span><span style="color:#308080;">)</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">list</span> <span style="color:#400000;">:t2</span> <span style="color:#008c00;">1</span> <span style="color:#008c00;">1</span> <span style="color:#008c00;">0</span> <span style="color:#008000;">0.15</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span>

<span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">test-fixture</span>
 <span style="color:#400000;">:results-model</span>
 <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">:setup</span> <span style="color:#308080;">(</span><span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">db</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">make-database</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span>
          <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">model</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">make-results-model</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span>
   <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">connect-db</span> model db<span style="color:#308080;">)</span><span style="color:#308080;">)</span>
 <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">:tests</span>
   <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">should-transmit-result-totals</span>
    <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">let</span> <span style="color:#308080;">(</span><span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">totals</span> <span style="color:#406080;">'</span><span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">"0</span> Total Test<span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">s</span><span style="color:#308080;">)</span><span style="color:#1060b6;">" "</span><span style="color:#008c00;">0</span> Assertions<span style="color:#1060b6;">" "</span><span style="color:#008c00;">0</span> Passes<span style="color:#1060b6;">" "</span><span style="color:#008c00;">0</span> Failures<span style="color:#1060b6;">" "</span><span style="color:#008c00;">0</span> Errors"
           <span style="color:#1060b6;">"0.000 Second(s)"</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span>
      <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">assert-equal</span> totals <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">get-result-totals</span> model<span style="color:#308080;">)</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span>

   <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">should-insert-result-data</span>
    <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">let</span> <span style="color:#308080;">(</span><span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">totals</span> <span style="color:#406080;">'</span><span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">"1</span> Total Test<span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">s</span><span style="color:#308080;">)</span><span style="color:#1060b6;">" "</span><span style="color:#008c00;">1</span> Assertions<span style="color:#1060b6;">" "</span><span style="color:#008c00;">1</span> Passes<span style="color:#1060b6;">" "</span><span style="color:#008c00;">0</span> Failures<span style="color:#1060b6;">" "</span><span style="color:#008c00;">0</span> Errors"
           <span style="color:#1060b6;">"0.000 Second(s)"</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span>
      <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">insert-result-data</span> model <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">list</span> <span style="color:#400000;">:no-name</span> <span style="color:#008c00;">1</span> <span style="color:#008c00;">1</span> <span style="color:#008c00;">0</span> <span style="color:#008000;">0.0</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span>
      <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">assert-equal</span> totals <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">get-result-totals</span> model<span style="color:#308080;">)</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span></pre>
<p>This is very conducive to programming incrementally.</p>
<p>The function we want to look at is <strong>get-result-totals</strong>. This function retrieve the totals from the database. We pass this then to <strong>result-sums</strong>. It&#8217;s results are then passed to<strong> format-results</strong>.</p>
<ol>
<li>Retrieve results from database.</li>
<li>Sum results.</li>
<li>Format results.</li>
</ol>
<p>Happy January!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/uglylispcode.wordpress.com/175/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/uglylispcode.wordpress.com/175/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/uglylispcode.wordpress.com/175/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/uglylispcode.wordpress.com/175/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/uglylispcode.wordpress.com/175/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/uglylispcode.wordpress.com/175/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/uglylispcode.wordpress.com/175/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/uglylispcode.wordpress.com/175/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/uglylispcode.wordpress.com/175/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/uglylispcode.wordpress.com/175/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/uglylispcode.wordpress.com/175/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/uglylispcode.wordpress.com/175/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/uglylispcode.wordpress.com/175/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/uglylispcode.wordpress.com/175/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=uglylispcode.wordpress.com&amp;blog=3958143&amp;post=175&amp;subd=uglylispcode&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://uglylispcode.wordpress.com/2009/01/05/object-programming-in-lisp-observation-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0b46bfc49b7ec609136bf30d273f80f7?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">gutzofter</media:title>
		</media:content>
	</item>
		<item>
		<title>An Object in Lisp. Part 6</title>
		<link>http://uglylispcode.wordpress.com/2009/01/02/an-object-in-lisp-part-6/</link>
		<comments>http://uglylispcode.wordpress.com/2009/01/02/an-object-in-lisp-part-6/#comments</comments>
		<pubDate>Fri, 02 Jan 2009 08:35:18 +0000</pubDate>
		<dc:creator>gutzofter</dc:creator>
				<category><![CDATA[Lisp Programming]]></category>
		<category><![CDATA[OOP]]></category>
		<category><![CDATA[Lisp]]></category>

		<guid isPermaLink="false">http://uglylispcode.wordpress.com/?p=176</guid>
		<description><![CDATA[What a way to start a little update on the the object framework that I have been pushing on. The last update talked about &#8216;destructuring-bind&#8216;. I had an epipheny the other day when I was trying to tdd a way to create generic functions for the framework. That led me to throwing away the destructuring-bind. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=uglylispcode.wordpress.com&amp;blog=3958143&amp;post=176&amp;subd=uglylispcode&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>What a way to start a little update on the the object framework that I have been pushing on.</p>
<p>The last update talked about &#8216;<a href="http://uglylispcode.wordpress.com/2008/12/18/an-object-in-lisp-part-5/">destructuring-bind</a>&#8216;. I had an epipheny the other day when I was trying to tdd a way to create generic functions for the framework. That led me to throwing away the destructuring-bind.</p>
<p>In order to explain my reasoning we need to go back to the representation of an object in the framework. The representation is a list of closures referenced by properties.</p>
<pre style="color:#000020;background:#f6f8ff;"><span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">defun</span> hello <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">obj</span> <span style="color:#400000;">&amp;rest</span> args<span style="color:#308080;">)</span>
  <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">apply</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">getf</span> obj <span style="color:#400000;">:hello</span><span style="color:#308080;">)</span> args<span style="color:#308080;">)</span>

<span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">defvar</span> hold1 <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">list</span> <span style="color:#400000;">:hello</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">lambda</span> <span style="color:#308080;">(</span><span style="color:#308080;">)</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">print</span> <span style="color:#406080;">'hello</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span>
<span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">defvar</span> hold2 <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">list</span> <span style="color:#400000;">:hello</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">lambda</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">x</span><span style="color:#308080;">)</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">print</span> x<span style="color:#308080;">)</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span></pre>
<p>The above lists can be accessed with a <strong>getf </strong>that retrieves the lambda from the list. To execute the lambda just <strong>apply</strong>. The<strong> hello</strong> defun above will handle either list as<strong> obj</strong>.</p>
<p>Something that I now know,  is that the lambda does its own destructuring-bind on its parameter list.  So here is how I create the accessor function for all objects  (generic and multiple signatures):</p>
<pre style="color:#000020;background:#f6f8ff;"><span style="color:#308080;"><strong>(</strong></span><span style="color:#200080;font-weight:bold;"><strong>defmacro</strong></span><strong> make-property <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">name</span><span style="color:#308080;">)</span>
  <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">let</span> <span style="color:#308080;">(</span><span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">g</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">gensym</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span>
    <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">multiple-value-bind</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">sym-name</span> key-name<span style="color:#308080;">)</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">symbol-and-keyword</span> name<span style="color:#308080;">)</span>
      `<span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">progn</span>
         <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">if</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">not</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">fboundp</span> <span style="color:#406080;">'</span><span style="color:#0066ee;">,sym-name</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span>
             <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">defun</span> <span style="color:#0066ee;">,sym-name</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">obj</span> <span style="color:#400000;">&amp;rest</span> <span style="color:#0066ee;">,g</span><span style="color:#308080;">)</span>
               <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">block</span> <span style="color:#0066ee;">,sym-name</span>
                 <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">apply</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">getf</span> obj <span style="color:#0066ee;">,key-name</span><span style="color:#308080;">)</span> <span style="color:#0066ee;">,g</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span></strong></pre>
<p><strong>Happy New Year!</strong></p>
<p>gutzofter</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/uglylispcode.wordpress.com/176/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/uglylispcode.wordpress.com/176/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/uglylispcode.wordpress.com/176/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/uglylispcode.wordpress.com/176/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/uglylispcode.wordpress.com/176/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/uglylispcode.wordpress.com/176/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/uglylispcode.wordpress.com/176/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/uglylispcode.wordpress.com/176/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/uglylispcode.wordpress.com/176/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/uglylispcode.wordpress.com/176/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/uglylispcode.wordpress.com/176/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/uglylispcode.wordpress.com/176/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/uglylispcode.wordpress.com/176/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/uglylispcode.wordpress.com/176/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=uglylispcode.wordpress.com&amp;blog=3958143&amp;post=176&amp;subd=uglylispcode&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://uglylispcode.wordpress.com/2009/01/02/an-object-in-lisp-part-6/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0b46bfc49b7ec609136bf30d273f80f7?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">gutzofter</media:title>
		</media:content>
	</item>
		<item>
		<title>Lisp Programming Trick #2</title>
		<link>http://uglylispcode.wordpress.com/2008/12/22/lisp-programming-trick-2/</link>
		<comments>http://uglylispcode.wordpress.com/2008/12/22/lisp-programming-trick-2/#comments</comments>
		<pubDate>Mon, 22 Dec 2008 12:54:31 +0000</pubDate>
		<dc:creator>gutzofter</dc:creator>
				<category><![CDATA[Domain Specific Language]]></category>
		<category><![CDATA[Lisp Programming]]></category>
		<category><![CDATA[dsl]]></category>
		<category><![CDATA[Syntactic Sugar]]></category>

		<guid isPermaLink="false">http://uglylispcode.wordpress.com/?p=167</guid>
		<description><![CDATA[Recursive Condition This little trick hit me when I was perusing PCL. Specifically, the when selector. (defun rec-cond (key) (cond ((eq key :before) (format nil "executing before" )) ((eq key :during) (format nil "executing during" )) ((eq key :after) (format nil "executing after" )) ((eq key :set-up) (rec-cond :before)) ((eq key :init) (rec-cond :before)) ((eq [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=uglylispcode.wordpress.com&amp;blog=3958143&amp;post=167&amp;subd=uglylispcode&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><strong>Recursive Condition</strong></p>
<p>This little trick hit me when I was perusing <a href="http://gigamonkeys.com/book/practical-a-simple-database.html">PCL</a>. Specifically, the when selector.</p>
<pre style="color:#000020;background:#f6f8ff;"><span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">defun</span> rec-cond <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">key</span><span style="color:#308080;">)</span>
  <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">cond</span>
    <span style="color:#308080;">(</span><span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">eq</span> key <span style="color:#400000;">:before</span><span style="color:#308080;">)</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">format</span> <span style="color:#7d0045;">nil</span> <span style="color:#1060b6;">"executing before"</span> <span style="color:#308080;">)</span><span style="color:#308080;">)</span>
    <span style="color:#308080;">(</span><span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">eq</span> key <span style="color:#400000;">:during</span><span style="color:#308080;">)</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">format</span> <span style="color:#7d0045;">nil</span> <span style="color:#1060b6;">"executing during"</span> <span style="color:#308080;">)</span><span style="color:#308080;">)</span>
    <span style="color:#308080;">(</span><span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">eq</span> key <span style="color:#400000;">:after</span><span style="color:#308080;">)</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">format</span> <span style="color:#7d0045;">nil</span> <span style="color:#1060b6;">"executing after"</span> <span style="color:#308080;">)</span><span style="color:#308080;">)</span>

    <span style="color:#308080;">(</span><span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">eq</span> key <span style="color:#400000;">:set-up</span><span style="color:#308080;">)</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">rec-cond</span> <span style="color:#400000;">:before</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span>
    <span style="color:#308080;">(</span><span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">eq</span> key <span style="color:#400000;">:init</span><span style="color:#308080;">)</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">rec-cond</span> <span style="color:#400000;">:before</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span>

    <span style="color:#308080;">(</span><span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">eq</span> key <span style="color:#400000;">:teardown</span><span style="color:#308080;">)</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">rec-cond</span> <span style="color:#400000;">:after</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span>

    <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">t</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">error</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">format</span> <span style="color:#7d0045;">nil</span> <span style="color:#1060b6;">"unknown command: ~A"</span> key<span style="color:#308080;">)</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span></pre>
<p>This overloads keyword symbols so that you more than one keyword can execute the same code.<span id="more-167"></span><strong>Syntactic Sugar</strong></p>
<pre style="color:#000020;background:#f6f8ff;"><span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">defun</span> num <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">key</span><span style="color:#308080;">)</span>
  <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">cond</span>
    <span style="color:#308080;">(</span><span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">eq</span> key <span style="color:#400000;">:zero</span><span style="color:#308080;">)</span> <span style="color:#008c00;">0</span><span style="color:#308080;">)</span>
    <span style="color:#308080;">(</span><span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">eq</span> key <span style="color:#400000;">:one</span><span style="color:#308080;">)</span> <span style="color:#008c00;">1</span><span style="color:#308080;">)</span>
    <span style="color:#308080;">(</span><span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">eq</span> key <span style="color:#400000;">:two</span><span style="color:#308080;">)</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">1+</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">num</span> <span style="color:#400000;">:one</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span>
    <span style="color:#308080;">(</span><span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">eq</span> key <span style="color:#400000;">:three</span><span style="color:#308080;">)</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">1+</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">num</span> <span style="color:#400000;">:two</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span>
    <span style="color:#308080;">(</span><span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">eq</span> key <span style="color:#400000;">:four</span><span style="color:#308080;">)</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">1+</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">num</span> <span style="color:#400000;">:three</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span>
    <span style="color:#308080;">(</span><span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">eq</span> key <span style="color:#400000;">:five</span><span style="color:#308080;">)</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">1+</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">num</span> <span style="color:#400000;">:four</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span>
    <span style="color:#308080;">(</span><span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">eq</span> key <span style="color:#400000;">:six</span><span style="color:#308080;">)</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">1+</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">num</span> <span style="color:#400000;">:five</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span>
    <span style="color:#308080;">(</span><span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">eq</span> key <span style="color:#400000;">:seven</span><span style="color:#308080;">)</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">1+</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">num</span> <span style="color:#400000;">:six</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span>
    <span style="color:#308080;">(</span><span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">eq</span> key <span style="color:#400000;">:eight</span><span style="color:#308080;">)</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">1+</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">num</span> <span style="color:#400000;">:seven</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span>
    <span style="color:#308080;">(</span><span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">eq</span> key <span style="color:#400000;">:nine</span><span style="color:#308080;">)</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">1+</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">num</span> <span style="color:#400000;">:eight</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span>
    <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">t</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">error</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">format</span> <span style="color:#7d0045;">nil</span> <span style="color:#1060b6;">"unknown number keyword: ~A"</span> key<span style="color:#308080;">)</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span>

<span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">test-fixture</span>
 <span style="color:#400000;">:num</span>
 <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">:tests</span>
   <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">should-do-my-key-numbers</span>
    <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">assert-equal</span> <span style="color:#008c00;">0</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">num</span> <span style="color:#400000;">:zero</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span>
    <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">assert-equal</span> <span style="color:#008c00;">1</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">num</span> <span style="color:#400000;">:one</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span>
    <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">assert-equal</span> <span style="color:#008c00;">2</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">num</span> <span style="color:#400000;">:two</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span>
    <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">assert-equal</span> <span style="color:#008c00;">3</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">num</span> <span style="color:#400000;">:three</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span>
    <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">assert-equal</span> <span style="color:#008c00;">4</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">num</span> <span style="color:#400000;">:four</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span>
    <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">assert-equal</span> <span style="color:#008c00;">5</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">num</span> <span style="color:#400000;">:five</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span>
    <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">assert-equal</span> <span style="color:#008c00;">6</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">num</span> <span style="color:#400000;">:six</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span>
    <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">assert-equal</span> <span style="color:#008c00;">7</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">num</span> <span style="color:#400000;">:seven</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span>
    <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">assert-equal</span> <span style="color:#008c00;">8</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">num</span> <span style="color:#400000;">:eight</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span>
    <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">assert-equal</span> <span style="color:#008c00;">9</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">num</span> <span style="color:#400000;">:nine</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span>
    <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">assert-error</span> <span style="color:#406080;">'simple-error</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">num</span> <span style="color:#400000;">:haha</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span>

   <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">should-do-basic-math</span>
    <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">assert-equal</span> <span style="color:#008c00;">5</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">+</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">num</span> <span style="color:#400000;">:two</span><span style="color:#308080;">)</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">num</span> <span style="color:#400000;">:three</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span>
    <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">assert-equal</span> <span style="color:#008c00;">5</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">-</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">num</span> <span style="color:#400000;">:eight</span><span style="color:#308080;">)</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">num</span> <span style="color:#400000;">:three</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span>
    <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">assert-equal</span> <span style="color:#008c00;">6</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">*</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">num</span> <span style="color:#400000;">:two</span><span style="color:#308080;">)</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">num</span> <span style="color:#400000;">:three</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span>
    <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">assert-equal</span> <span style="color:#008c00;">2</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">/</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">num</span> <span style="color:#400000;">:six</span><span style="color:#308080;">)</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">num</span> <span style="color:#400000;">:three</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span></pre>
<p>But who the hell wants to write num function and then keyword.</p>
<p>This might me a little better.</p>
<pre style="color:#000020;background:#f6f8ff;"><span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">defmacro</span> with-numbers <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">&amp;rest</span> rest<span style="color:#308080;">)</span>
  `<span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">let</span> <span style="color:#308080;">(</span><span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">zero</span> <span style="color:#008c00;">0</span><span style="color:#308080;">)</span>
         <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">one</span> <span style="color:#008c00;">1</span><span style="color:#308080;">)</span>
         <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">two</span> <span style="color:#008c00;">2</span><span style="color:#308080;">)</span>
         <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">three</span> <span style="color:#008c00;">3</span><span style="color:#308080;">)</span>
         <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">four</span> <span style="color:#008c00;">4</span><span style="color:#308080;">)</span>
         <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">five</span> <span style="color:#008c00;">5</span><span style="color:#308080;">)</span>
         <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">six</span> <span style="color:#008c00;">6</span><span style="color:#308080;">)</span>
         <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">seven</span> <span style="color:#008c00;">7</span><span style="color:#308080;">)</span>
         <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">eight</span> <span style="color:#008c00;">8</span><span style="color:#308080;">)</span>
         <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">nine</span> <span style="color:#008c00;">9</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span>
     <span style="color:#0066ee;">,@rest</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span>

<span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">test-fixture</span>
 <span style="color:#400000;">:num-with-sugar</span>
 <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">:tests</span>
   <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">should-use-sugar-number</span>
    <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">with-numbers</span>
     <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">assert-equal</span> <span style="color:#008c00;">0</span> zero<span style="color:#308080;">)</span>
     <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">assert-equal</span> <span style="color:#008c00;">1</span> one<span style="color:#308080;">)</span>
     <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">assert-equal</span> <span style="color:#008c00;">2</span> two<span style="color:#308080;">)</span>
     <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">assert-equal</span> <span style="color:#008c00;">3</span> three<span style="color:#308080;">)</span>
     <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">assert-equal</span> <span style="color:#008c00;">4</span> four<span style="color:#308080;">)</span>
     <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">assert-equal</span> <span style="color:#008c00;">5</span> five<span style="color:#308080;">)</span>
     <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">assert-equal</span> <span style="color:#008c00;">6</span> six<span style="color:#308080;">)</span>
     <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">assert-equal</span> <span style="color:#008c00;">7</span> seven<span style="color:#308080;">)</span>
     <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">assert-equal</span> <span style="color:#008c00;">8</span> eight<span style="color:#308080;">)</span>
     <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">assert-equal</span> <span style="color:#008c00;">9</span> nine<span style="color:#308080;">)</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span>

   <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">should-sugar-do-basic-math</span>
    <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">with-numbers</span>
     <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">assert-equal</span> <span style="color:#008c00;">5</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">+</span> two three<span style="color:#308080;">)</span><span style="color:#308080;">)</span>
     <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">assert-equal</span> <span style="color:#008c00;">5</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">-</span> eight three<span style="color:#308080;">)</span><span style="color:#308080;">)</span>
     <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">assert-equal</span> <span style="color:#008c00;">6</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">*</span> two three<span style="color:#308080;">)</span><span style="color:#308080;">)</span>
     <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">assert-equal</span> <span style="color:#008c00;">2</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">/</span> six three<span style="color:#308080;">)</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span></pre>
<p>I believe that if you use format you can also get something similar. Just intern string to symbol.</p>
<pre style="color:#000020;background:#f6f8ff;"><span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">intern</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">string-upcase</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">format</span> <span style="color:#7d0045;">nil</span> <span style="color:#1060b6;">"~r"</span> <span style="color:#008c00;">0</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span></pre>
<p>I think I&#8217;m going to start using different titles for these type of posts.</p>
<p>What do you think?</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/uglylispcode.wordpress.com/167/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/uglylispcode.wordpress.com/167/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/uglylispcode.wordpress.com/167/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/uglylispcode.wordpress.com/167/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/uglylispcode.wordpress.com/167/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/uglylispcode.wordpress.com/167/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/uglylispcode.wordpress.com/167/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/uglylispcode.wordpress.com/167/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/uglylispcode.wordpress.com/167/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/uglylispcode.wordpress.com/167/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/uglylispcode.wordpress.com/167/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/uglylispcode.wordpress.com/167/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/uglylispcode.wordpress.com/167/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/uglylispcode.wordpress.com/167/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=uglylispcode.wordpress.com&amp;blog=3958143&amp;post=167&amp;subd=uglylispcode&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://uglylispcode.wordpress.com/2008/12/22/lisp-programming-trick-2/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0b46bfc49b7ec609136bf30d273f80f7?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">gutzofter</media:title>
		</media:content>
	</item>
		<item>
		<title>Test Driven Development As an Introduction</title>
		<link>http://uglylispcode.wordpress.com/2008/12/19/test-driven-development-as-an-introduction/</link>
		<comments>http://uglylispcode.wordpress.com/2008/12/19/test-driven-development-as-an-introduction/#comments</comments>
		<pubDate>Fri, 19 Dec 2008 23:09:36 +0000</pubDate>
		<dc:creator>gutzofter</dc:creator>
				<category><![CDATA[TDD]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Promotional]]></category>
		<category><![CDATA[Test Driven]]></category>

		<guid isPermaLink="false">http://uglylispcode.wordpress.com/?p=156</guid>
		<description><![CDATA[I recommend Clarke Ching&#8217;s TDD Test Drive for an introduction for TDD. It is pretty good. Have Fun!<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=uglylispcode.wordpress.com&amp;blog=3958143&amp;post=156&amp;subd=uglylispcode&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I recommend <a href="http://www.tddtestdrive.com/">Clarke Ching&#8217;s TDD Test Drive</a> for an introduction for TDD.</p>
<p>It is pretty good.</p>
<p>Have Fun!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/uglylispcode.wordpress.com/156/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/uglylispcode.wordpress.com/156/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/uglylispcode.wordpress.com/156/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/uglylispcode.wordpress.com/156/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/uglylispcode.wordpress.com/156/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/uglylispcode.wordpress.com/156/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/uglylispcode.wordpress.com/156/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/uglylispcode.wordpress.com/156/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/uglylispcode.wordpress.com/156/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/uglylispcode.wordpress.com/156/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/uglylispcode.wordpress.com/156/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/uglylispcode.wordpress.com/156/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/uglylispcode.wordpress.com/156/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/uglylispcode.wordpress.com/156/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=uglylispcode.wordpress.com&amp;blog=3958143&amp;post=156&amp;subd=uglylispcode&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://uglylispcode.wordpress.com/2008/12/19/test-driven-development-as-an-introduction/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0b46bfc49b7ec609136bf30d273f80f7?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">gutzofter</media:title>
		</media:content>
	</item>
		<item>
		<title>An Object in Lisp. Part 5</title>
		<link>http://uglylispcode.wordpress.com/2008/12/18/an-object-in-lisp-part-5/</link>
		<comments>http://uglylispcode.wordpress.com/2008/12/18/an-object-in-lisp-part-5/#comments</comments>
		<pubDate>Fri, 19 Dec 2008 00:41:15 +0000</pubDate>
		<dc:creator>gutzofter</dc:creator>
				<category><![CDATA[Lisp Programming]]></category>
		<category><![CDATA[OOP]]></category>
		<category><![CDATA[Lisp]]></category>

		<guid isPermaLink="false">http://uglylispcode.wordpress.com/?p=153</guid>
		<description><![CDATA[Destructuring Bind &#8230; binds the variables specified in lambda-list to the corresponding values in the tree structure resulting from the evaluation of expression; then destructuring-bind evaluates forms. &#8216;destructuring-bind&#8216; is a wonderful macro. The first thing you do is hand it a lambda list and a list of values. It acts like a pattern matcher. If [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=uglylispcode.wordpress.com&amp;blog=3958143&amp;post=153&amp;subd=uglylispcode&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><strong>Destructuring Bind</strong></p>
<p>&#8230; binds the variables specified in lambda-list to the corresponding values in the tree structure resulting from the evaluation of expression; then destructuring-bind evaluates forms.</p>
<p><a href="http://www.lispworks.com/documentation/HyperSpec/Body/m_destru.htm">&#8216;destructuring-bind</a>&#8216; is a wonderful macro. The first thing you do is hand it a lambda list and a list of values. It acts like a pattern matcher. If the list of values does not match up to the lambda list it will throw an error.</p>
<p>Here is what I&#8217;m talking about:</p>
<pre style="color:#000020;background:#f6f8ff;"><span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">defun</span> test-d-bind <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">&amp;rest</span> args<span style="color:#308080;">)</span>
  <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">destructuring-bind</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">a</span> <span style="color:#400000;">&amp;optional</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">b</span> <span style="color:#008c00;">3</span><span style="color:#308080;">)</span> <span style="color:#400000;">&amp;rest</span> x <span style="color:#400000;">&amp;key</span> c <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">d</span> a<span style="color:#308080;">)</span><span style="color:#308080;">)</span> args
    <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">list</span> a b c d x<span style="color:#308080;">)</span><span style="color:#308080;">)</span></pre>
<pre style="color:#000020;background:#f6f8ff;"><span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">test-d-bind</span> <span style="color:#7d0045;">nil</span><span style="color:#308080;">)</span>
<span style="color:#595979;">;&gt;&gt;(NIL 3 NIL NIL NIL)</span>
<span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">test-d-bind</span> <span style="color:#008c00;">1</span> <span style="color:#008c00;">6</span> <span style="color:#400000;">:d</span> <span style="color:#008c00;">8</span> <span style="color:#400000;">:c</span> <span style="color:#008c00;">9</span> <span style="color:#400000;">:d</span> <span style="color:#008c00;">10</span><span style="color:#308080;">)</span>
<span style="color:#595979;">;&gt;&gt;(1 6 9 8 (:D 8 :C 9 :D 10)</span></pre>
<p><strong><span id="more-153"></span>Parameter Keywords</strong></p>
<p>A <a rel="DEFINITION" href="http://www.lispworks.com/documentation/HyperSpec/Body/26_glo_m.htm#macro_lambda_list"><em>macro lambda list</em></a> can contain the <a rel="DEFINITION" href="http://www.lispworks.com/documentation/HyperSpec/Body/26_glo_l.htm#lambda_list_keyword"><em>lambda list keywords</em></a>:</p>
<pre>&amp;allow-other-keys                 &amp;environment</pre>
<pre>&amp;rest                             &amp;aux</pre>
<pre>&amp;key                              &amp;whole</pre>
<pre>&amp;body                             &amp;optional</pre>
<p>An <a rel="DEFINITION" href="http://www.lispworks.com/documentation/HyperSpec/Body/26_glo_o.htm#ordinary_lambda_list"><em>ordinary lambda list</em></a> can contain the <a rel="DEFINITION" href="http://www.lispworks.com/documentation/HyperSpec/Body/26_glo_l.htm#lambda_list_keyword"><em>lambda list keywords:</em></a></p>
<pre>&amp;allow-other-keys                 &amp;key</pre>
<pre>&amp;rest                             &amp;aux
&amp;optional</pre>
<p>The object framework that I&#8217;ve been covering couldn&#8217;t handle parameter keywords. Now it can. This is all due to destructuring-bind. A very universal macro. I believe that because of this macro I will be able to add generic function for all objects and also multiple function signatures.</p>
<pre style="color:#000020;background:#f6f8ff;"><span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">defmacro</span> make-property <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">name</span> args<span style="color:#308080;">)</span>
  <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">let</span> <span style="color:#308080;">(</span><span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">g</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">gensym</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span>
        <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">r-args</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">remove-if-not-symbol</span> args<span style="color:#308080;">)</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span>
    <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">multiple-value-bind</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">sym-name</span> key-name<span style="color:#308080;">)</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">symbol-and-keyword</span> name<span style="color:#308080;">)</span>
      `<span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">progn</span>
         <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">defun</span> <span style="color:#0066ee;">,sym-name</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">obj</span> <span style="color:#400000;">&amp;rest</span> <span style="color:#0066ee;">,g</span><span style="color:#308080;">)</span>
           <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">block</span> <span style="color:#0066ee;">,sym-name</span>
             <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">destructuring-bind</span> <span style="color:#0066ee;">,args</span> <span style="color:#0066ee;">,g</span>
               <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">declare</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">ignorable</span> <span style="color:#0066ee;">,@r-args</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span>
               <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">apply</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">getf</span> obj <span style="color:#0066ee;">,key-name</span><span style="color:#308080;">)</span> <span style="color:#0066ee;">,g</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span></pre>
<p><strong>Future speculation</strong></p>
<p>Generic function and multiple function signatures can be derived from the above code. Looking at the above code we see that the destructuring-bind is embedded within the defun block. Right now we overwrite any previously defun-ed function.</p>
<ul>
<li>store &#8216;args into a list, then using name as key store the list into a hash (args-template table). The &#8216;args will be considered an instance of a template.</li>
<li>wrap an error-handler around destructuring-bind and then iterate through the templates to see if a match. If not add to templates table.</li>
</ul>
<p>Happy Snow Days!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/uglylispcode.wordpress.com/153/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/uglylispcode.wordpress.com/153/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/uglylispcode.wordpress.com/153/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/uglylispcode.wordpress.com/153/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/uglylispcode.wordpress.com/153/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/uglylispcode.wordpress.com/153/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/uglylispcode.wordpress.com/153/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/uglylispcode.wordpress.com/153/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/uglylispcode.wordpress.com/153/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/uglylispcode.wordpress.com/153/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/uglylispcode.wordpress.com/153/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/uglylispcode.wordpress.com/153/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/uglylispcode.wordpress.com/153/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/uglylispcode.wordpress.com/153/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=uglylispcode.wordpress.com&amp;blog=3958143&amp;post=153&amp;subd=uglylispcode&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://uglylispcode.wordpress.com/2008/12/18/an-object-in-lisp-part-5/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0b46bfc49b7ec609136bf30d273f80f7?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">gutzofter</media:title>
		</media:content>
	</item>
		<item>
		<title>Read it Later &#8211; Make your browsing a breeze</title>
		<link>http://uglylispcode.wordpress.com/2008/12/11/read-it-later/</link>
		<comments>http://uglylispcode.wordpress.com/2008/12/11/read-it-later/#comments</comments>
		<pubDate>Fri, 12 Dec 2008 03:28:13 +0000</pubDate>
		<dc:creator>gutzofter</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Promotional]]></category>

		<guid isPermaLink="false">http://uglylispcode.wordpress.com/?p=149</guid>
		<description><![CDATA[This is a must have. Creating a list of the links to review later instead of opening tabs. Read It Later<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=uglylispcode.wordpress.com&amp;blog=3958143&amp;post=149&amp;subd=uglylispcode&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This is a must have. Creating a list of the links to review later instead of opening tabs.</p>
<p><a href="http://www.ideashower.com/ideas/launched/read-it-later/">Read It Later</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/uglylispcode.wordpress.com/149/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/uglylispcode.wordpress.com/149/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/uglylispcode.wordpress.com/149/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/uglylispcode.wordpress.com/149/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/uglylispcode.wordpress.com/149/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/uglylispcode.wordpress.com/149/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/uglylispcode.wordpress.com/149/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/uglylispcode.wordpress.com/149/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/uglylispcode.wordpress.com/149/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/uglylispcode.wordpress.com/149/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/uglylispcode.wordpress.com/149/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/uglylispcode.wordpress.com/149/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/uglylispcode.wordpress.com/149/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/uglylispcode.wordpress.com/149/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=uglylispcode.wordpress.com&amp;blog=3958143&amp;post=149&amp;subd=uglylispcode&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://uglylispcode.wordpress.com/2008/12/11/read-it-later/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0b46bfc49b7ec609136bf30d273f80f7?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">gutzofter</media:title>
		</media:content>
	</item>
		<item>
		<title>And Behind Door Number 2 Is . . . A Leaky Abstraction</title>
		<link>http://uglylispcode.wordpress.com/2008/12/11/and-behind-door-number-2-is/</link>
		<comments>http://uglylispcode.wordpress.com/2008/12/11/and-behind-door-number-2-is/#comments</comments>
		<pubDate>Thu, 11 Dec 2008 17:56:16 +0000</pubDate>
		<dc:creator>gutzofter</dc:creator>
				<category><![CDATA[Lisp Programming]]></category>
		<category><![CDATA[Abstraction]]></category>
		<category><![CDATA[Liskov Substitution Principle]]></category>
		<category><![CDATA[OOP]]></category>
		<category><![CDATA[Syntatic Sugar]]></category>

		<guid isPermaLink="false">http://uglylispcode.wordpress.com/?p=140</guid>
		<description><![CDATA[Liskov Substitution  Principle (LSP): Let q(x) be a property provable about objects x of type T. Then q(y) should be true for objects y of type S where S is a subtype of T. My Bogus was an attempt to abstract a method by which I could get access to a variable using a syntatic-sugar [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=uglylispcode.wordpress.com&amp;blog=3958143&amp;post=140&amp;subd=uglylispcode&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://en.wikipedia.org/wiki/Liskov_substitution_principle">Liskov Substitution  Principle (LSP): </a></p>
<dl>
<dd><em>Let <span class="texhtml"><em>q</em>(<em>x</em>)</span> be a <a title="Property (programming)" href="http://en.wikipedia.org/wiki/Property_%28programming%29">property</a> provable about objects <span class="texhtml"><em>x</em></span> of type <span class="texhtml"><em>T</em></span>. Then <span class="texhtml"><em>q</em>(<em>y</em>)</span> should be true for objects <span class="texhtml"><em>y</em></span> of type <span class="texhtml"><em>S</em></span> where <span class="texhtml"><em>S</em></span> is a subtype of <span class="texhtml"><em>T</em></span>.</em></dd>
</dl>
<p><a href="http://uglylispcode.wordpress.com/2008/12/07/lisp-trick-1/"><strong>My Bogus</strong></a> was an attempt to abstract a method by which I could get access to a variable using a syntatic-sugar idiom. The abstraction leaks. Here is how it leaks:</p>
<pre style="color:#000020;background:#f6f8ff;"><span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">should-maintain-scope-of-inner-property</span>
       <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">with-property</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">value</span> <span style="color:#008c00;">24</span><span style="color:#308080;">)</span>
         <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">value</span> <span style="color:#400000;">:is</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">incf</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">value</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span>
       <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">assert-equal</span> <span style="color:#008c00;">25</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">value</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span></pre>
<p>&#8216;incf&#8217; is a destructive operation.</p>
<p><span id="more-140"></span>Here is a possible implementation of &#8216;incf&#8217;:</p>
<pre style="color:#000020;background:#f6f8ff;"><span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">defmacro</span> my-incf <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">place</span> <span style="color:#400000;">&amp;optional</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">val</span> <span style="color:#008c00;">1</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span>
  <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">let</span> <span style="color:#308080;">(</span><span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">v</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">gensym</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span>
        <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">a</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">gensym</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span>
    `<span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">let*</span> <span style="color:#308080;">(</span><span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">,v</span> <span style="color:#0066ee;">,val</span><span style="color:#308080;">)</span>
            <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">,a</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">+</span> <span style="color:#0066ee;">,place</span> <span style="color:#0066ee;">,v</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span>
       <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">setf</span> <span style="color:#0066ee;">,place</span> <span style="color:#0066ee;">,a</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span></pre>
<p>It&#8217;s that last form<strong> (setf ,place ,a)</strong> that breaks the LSP. The only way we can change the actual value of my abstraction is with the keyword symbol <strong>:is</strong>. So in the end, the operation we were trying to abstract out is what causes the<a href="http://www.joelonsoftware.com/articles/LeakyAbstractions.html"> abstraction to leak</a>.</p>
<p>I still think that there is some promise here, it just needs to be pushed on some more.</p>
<p>I would like to thank <a href="http://xach.livejournal.com/">Zach Beane</a> for his cogent and very lucid comments of why this abstraction was bogus. His very technical discussion was very enlightening. <a href="http://www.xach.com/">I recommend this also</a>.</p>
<p>References:</p>
<p>On Lisp still amazes me with the amount of information in it. My understanding if &#8216;incf&#8217; comes from this. Use the <a href="http://www.bookshelf.jp/texi/onlisp/onlisp.html#SEC_Top">on-line</a> version and do searches.</p>
<p>Another nice read is <a href="http://www.dreamsongs.com/Separation.html">&#8220;Technical Issues of Separation in Function Cells and Value Cells&#8221;</a>.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/uglylispcode.wordpress.com/140/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/uglylispcode.wordpress.com/140/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/uglylispcode.wordpress.com/140/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/uglylispcode.wordpress.com/140/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/uglylispcode.wordpress.com/140/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/uglylispcode.wordpress.com/140/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/uglylispcode.wordpress.com/140/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/uglylispcode.wordpress.com/140/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/uglylispcode.wordpress.com/140/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/uglylispcode.wordpress.com/140/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/uglylispcode.wordpress.com/140/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/uglylispcode.wordpress.com/140/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/uglylispcode.wordpress.com/140/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/uglylispcode.wordpress.com/140/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=uglylispcode.wordpress.com&amp;blog=3958143&amp;post=140&amp;subd=uglylispcode&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://uglylispcode.wordpress.com/2008/12/11/and-behind-door-number-2-is/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0b46bfc49b7ec609136bf30d273f80f7?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">gutzofter</media:title>
		</media:content>
	</item>
		<item>
		<title>Abstraction of an encapsulted property in Lisp</title>
		<link>http://uglylispcode.wordpress.com/2008/12/09/abstraction/</link>
		<comments>http://uglylispcode.wordpress.com/2008/12/09/abstraction/#comments</comments>
		<pubDate>Wed, 10 Dec 2008 00:25:34 +0000</pubDate>
		<dc:creator>gutzofter</dc:creator>
				<category><![CDATA[EDA]]></category>
		<category><![CDATA[Lisp Programming]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Abstraction]]></category>
		<category><![CDATA[Encapsulation]]></category>
		<category><![CDATA[Macro]]></category>

		<guid isPermaLink="false">http://uglylispcode.wordpress.com/?p=136</guid>
		<description><![CDATA[Abstraction (computer science): is a mechanism and practice to reduce and factor out details so that one can focus on a few concepts at a time. If you read Lisp Trick #1, hopefully, you saw a pretty good abstraction. What it was doing was abstracting out the setting and getting a value from a variable. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=uglylispcode.wordpress.com&amp;blog=3958143&amp;post=136&amp;subd=uglylispcode&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p class="firstHeading"><strong><a href="http://en.wikipedia.org/wiki/Abstraction_(computer_programming)">Abstraction (computer science)</a>: </strong>is a mechanism and practice to reduce and factor out details so that one can focus on a few concepts at a time.</p>
<p>If you read <a href="http://uglylispcode.wordpress.com/2008/12/07/lisp-trick-1/">Lisp Trick #1</a>, hopefully, you saw a pretty good abstraction. What it was doing was abstracting out the setting and getting a value from a variable. As a bonus, because of the way<em><strong> &amp;key</strong></em> parameter keyword can be used, we were able to differentiate whether you were getting the value or setting the variable. Another bonus is that the variable we are getting and setting is encapsulated.</p>
<p class="firstHeading">Usually an abstraction is created with the use of macros. Now I&#8217;ve made an even larger abstraction of the setter/getter abstraction.</p>
<p class="firstHeading"><span id="more-136"></span>Here it is:</p>
<pre style="color:#000020;background:#f6f8ff;"><span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">defmacro</span> with-property <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">property</span> <span style="color:#308080;">&amp;</span>body body<span style="color:#308080;">)</span>
  <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">when</span> property
    <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">let</span> <span style="color:#308080;">(</span><span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">p-n</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">first</span> property<span style="color:#308080;">)</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span>
      `<span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">let</span> <span style="color:#308080;">(</span><span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">,@property</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span>
         <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">defun</span> <span style="color:#0066ee;">,p-n</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">&amp;key</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">is</span> <span style="color:#7d0045;">nil</span> is-p<span style="color:#308080;">)</span><span style="color:#308080;">)</span>
           <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">cond</span>
             <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">is-p</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">setf</span> <span style="color:#0066ee;">,p-n</span> is<span style="color:#308080;">)</span><span style="color:#308080;">)</span>
             <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">t</span> <span style="color:#0066ee;">,p-n</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span>
         <span style="color:#0066ee;">,@body</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span>

<span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">test-fixture</span>
    <span style="color:#400000;">:with-property-macro</span>
    <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">:tests</span>
      <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">should-single-nil-property</span>
       <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">assert-equal</span> <span style="color:#7d0045;">nil</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">with-property</span> <span style="color:#7d0045;">nil</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span>

      <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">should-single-property</span>
       <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">assert-equal</span> <span style="color:#008c00;">1</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">with-property</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">value</span> <span style="color:#008c00;">1</span><span style="color:#308080;">)</span> value<span style="color:#308080;">)</span><span style="color:#308080;">)</span>
       <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">unintern</span> <span style="color:#406080;">'value</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span>

      <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">should-use-property</span>
       <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">with-property</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">value</span> <span style="color:#008c00;">1</span><span style="color:#308080;">)</span>
         <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">value</span> <span style="color:#400000;">:is</span> <span style="color:#008c00;">12</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span>
       <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">assert-equal</span> <span style="color:#008c00;">12</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">value</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span>
       <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">value</span> <span style="color:#400000;">:is</span> <span style="color:#008c00;">24</span><span style="color:#308080;">)</span>
       <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">assert-equal</span> <span style="color:#008c00;">24</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">value</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span>
       <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">unintern</span> <span style="color:#406080;">'value</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span>

      <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">should-not-capture-property</span>
       <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">let</span> <span style="color:#308080;">(</span><span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">property</span> <span style="color:#406080;">'property</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span>
         <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">with-property</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">property</span> <span style="color:#008c00;">8</span><span style="color:#308080;">)</span> property<span style="color:#308080;">)</span>
         <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">assert-equal</span> <span style="color:#008c00;">8</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">property</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span>
       <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">assert-equal</span> <span style="color:#008c00;">8</span> <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">property</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span>
       <span style="color:#308080;">(</span><span style="color:#200080;font-weight:bold;">unintern</span> <span style="color:#406080;">'property</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span><span style="color:#308080;">)</span></pre>
<p class="firstHeading">You&#8217;ll notice that the scope for the variable remains even after leaving the &#8216;with-property&#8217; abstraction. Right now I don&#8217;t know if that is good or bad. We&#8217;ll see.</p>
<p class="firstHeading">
<p class="firstHeading">NOTE: You need to review &#8220;<a href="http://uglylispcode.wordpress.com/2008/12/11/and-behind-door-number-2-is/">And Behind Door Number 2 Is . . .</a>&#8221; for an explanation of why this has a leaky abstraction.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/uglylispcode.wordpress.com/136/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/uglylispcode.wordpress.com/136/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/uglylispcode.wordpress.com/136/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/uglylispcode.wordpress.com/136/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/uglylispcode.wordpress.com/136/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/uglylispcode.wordpress.com/136/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/uglylispcode.wordpress.com/136/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/uglylispcode.wordpress.com/136/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/uglylispcode.wordpress.com/136/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/uglylispcode.wordpress.com/136/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/uglylispcode.wordpress.com/136/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/uglylispcode.wordpress.com/136/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/uglylispcode.wordpress.com/136/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/uglylispcode.wordpress.com/136/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=uglylispcode.wordpress.com&amp;blog=3958143&amp;post=136&amp;subd=uglylispcode&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://uglylispcode.wordpress.com/2008/12/09/abstraction/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0b46bfc49b7ec609136bf30d273f80f7?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">gutzofter</media:title>
		</media:content>
	</item>
	</channel>
</rss>
