<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xml:base="http://nolan.eakins.net" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
 <title>Nolan&#039;s Corner - Programming</title>
 <link>http://nolan.eakins.net/taxonomy/term/9/0</link>
 <description></description>
 <language>en</language>
<item>
 <title>RSpec matcher helper</title>
 <link>http://nolan.eakins.net/node/311</link>
 <description>&lt;p&gt;
I&#039;ve finally written more than one RSpec matcher. Creating a matcher essentially involves defining a class and a method that creates an instance of that class. Rather redundant, resulting in my RSpec matcher helper:
&lt;/p&gt;
&lt;pre&gt;
def defmatcher(name, &amp;code)
  klass = Class.new
  klass.module_eval(&amp;code)
  
  Object.send :define_method, name.to_s do |*args|
    klass.new(*args)
  end
end
&lt;/pre&gt;&lt;p&gt;
That little method, &lt;code&gt;defmatcher&lt;/code&gt;, creates the class and method for you. It saves some typing. An example can be found in the full source file, &lt;a href=&quot;/system/files/spec_matcher_dsl.rb&quot;&gt;available here&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Update (2008/06/28):&lt;/b&gt; RSpec was having trouble keeping this all in one file. I created a project at GitHub to host this for the time being: &lt;a href=&quot;http://github.com/sneakin/spec_matcher_helper/&quot;&gt;http://github.com/sneakin/spec_matcher_helper/&lt;/a&gt;&lt;/p&gt;
&lt;table id=&quot;attachments&quot;&gt;
 &lt;thead&gt;&lt;tr&gt;&lt;th&gt;Attachment&lt;/th&gt;&lt;th&gt;Size&lt;/th&gt; &lt;/tr&gt;&lt;/thead&gt;
&lt;tbody&gt;
 &lt;tr class=&quot;odd&quot;&gt;&lt;td&gt;&lt;a href=&quot;http://nolan.eakins.net/system/files/spec_matcher_dsl.rb&quot;&gt;spec_matcher_dsl.rb&lt;/a&gt;&lt;/td&gt;&lt;td&gt;1.45 KB&lt;/td&gt; &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
</description>
 <comments>http://nolan.eakins.net/node/311#comment</comments>
 <category domain="http://nolan.eakins.net/taxonomy/term/14">Personal</category>
 <category domain="http://nolan.eakins.net/taxonomy/term/9">Programming</category>
 <category domain="http://nolan.eakins.net/taxonomy/term/28">Rails</category>
 <enclosure url="http://nolan.eakins.net/system/files/spec_matcher_dsl.rb" length="1484" type="application/octet-stream" />
 <pubDate>Sat, 28 Jun 2008 16:25:54 -0700</pubDate>
 <dc:creator>sneakin</dc:creator>
 <guid isPermaLink="false">311 at http://nolan.eakins.net</guid>
</item>
<item>
 <title>Experiments with Erlang</title>
 <link>http://nolan.eakins.net/node/310</link>
 <description>&lt;p&gt;Earlier today I setup an instance of &lt;a href=&quot;http://hg.oss.semanticgap.com/&quot;&gt;HgWeb&lt;/a&gt; to host some old and new code bases of mine. Two of the repositories may interest those learning or looking to learn Erlang. Both repositories contain a simple project that doesn&#039;t amount to much of anything at the moment, though they could prove useful for some code reading/banging.&lt;/p&gt;
&lt;p&gt;The two repositories are:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;http://hg.oss.semanticgap.com/station&quot;&gt;Station&lt;/a&gt;: This is a super basic, simple HTTP server framework. It can currently parse an HTTP request which gets dispatched to a station behavior that you can define. The station behavior contains a function that gets called on each valid request and returns a response which is sent back to the requestor. Proper query string and form handling still needs to be done along with dispatching to different modules based on the requested path.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://hg.oss.semanticgap.com/mod_rest/trunk&quot;&gt;mod_rest&lt;/a&gt;: This is an &lt;a href=&quot;http://www.ejabberd.ru/&quot;&gt;ejabberd&lt;/a&gt; module that adds an HTTP handler that allows HTTP clients to literally post arbitrary message stanzas to ejabberd. Those stanzas then get shoved through ejabberd&#039;s router just like any other stanza. My original use for this was to allow a Rails app to send messages through ejabberd without needing to be a full XMPP client.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;You will need to install &lt;a href=&quot;http://www.selenic.com/mercurial/wiki/&quot;&gt;Mercurial&lt;/a&gt; to get the code onto your machine. It&#039;s the next best thing to git.&lt;/p&gt;</description>
 <comments>http://nolan.eakins.net/node/310#comment</comments>
 <category domain="http://nolan.eakins.net/taxonomy/term/29">Erlang</category>
 <category domain="http://nolan.eakins.net/taxonomy/term/11">Jabber</category>
 <category domain="http://nolan.eakins.net/taxonomy/term/14">Personal</category>
 <category domain="http://nolan.eakins.net/taxonomy/term/9">Programming</category>
 <pubDate>Sat, 07 Jun 2008 17:32:33 -0700</pubDate>
 <dc:creator>sneakin</dc:creator>
 <guid isPermaLink="false">310 at http://nolan.eakins.net</guid>
</item>
<item>
 <title>Dot Plots: A Coder&#039;s Towel</title>
 <link>http://nolan.eakins.net/node/309</link>
 <description>&lt;p&gt;I just slapped together a dot plotter after scanning through &lt;a href=&quot;http://www.iam.unibe.ch/~scg/OORP/&quot;&gt;Object-Oriented Reengineering Patterns&lt;/a&gt;. That book describes the use of &lt;a href=&quot;http://www.dcs.shef.ac.uk/nlp/meter/Workshop/Dotplot/Public/index.htm&quot;&gt;dot plots&lt;/a&gt; to detect duplicated code. While it&#039;s a bit like reading tea leaves, it is a good detector as the following two plots of dotplotter.rb against itself show with the huge run down the middle:&lt;/p&gt;
&lt;p&gt;
&lt;img src=&quot;/system/files/dotplot1.png&quot; alt=&quot;Dot Plot of dotplotter.rb against itself in Ruby mode (-r)&quot;/&gt;
&lt;img src=&quot;/system/files/dotplot2.png&quot; alt=&quot;Dot Plot of dotplotter.rb against itself in Line mode (-r)&quot;/&gt;
&lt;/p&gt;
&lt;p&gt;The first is dotplotter.rb running with the &quot;-r&quot; option which compares tokens to tokens thus making each row/column a token such as &quot;def&quot;. The second, smaller one is in line mode, &quot;-l&quot;, which compares lines with lines. That makes each row/column an actual line in the source file.&lt;/p&gt;
&lt;p&gt;The huge diagonal line through the middle indicates a huge run of duplicated code. That&#039;s because it&#039;s the same file against itself. Now if these were separate files, then the runs would hopefully not exist since any such run indicates duplication.&lt;/p&gt;
&lt;p&gt;The dot plot script can be found at the following site. It requires RMagick and ParseTree to work: &lt;a href=&quot;http://nolan.eakins.net/code/dotplotter.rb&quot;&gt;http://nolan.eakins.net/code/dotplotter.rb&lt;/a&gt;&lt;/p&gt;
&lt;!--break--&gt;&lt;table id=&quot;attachments&quot;&gt;
 &lt;thead&gt;&lt;tr&gt;&lt;th&gt;Attachment&lt;/th&gt;&lt;th&gt;Size&lt;/th&gt; &lt;/tr&gt;&lt;/thead&gt;
&lt;tbody&gt;
 &lt;tr class=&quot;odd&quot;&gt;&lt;td&gt;&lt;a href=&quot;http://nolan.eakins.net/system/files/dotplot2.png&quot;&gt;dotplot2.png&lt;/a&gt;&lt;/td&gt;&lt;td&gt;1.28 KB&lt;/td&gt; &lt;/tr&gt;
 &lt;tr class=&quot;even&quot;&gt;&lt;td&gt;&lt;a href=&quot;http://nolan.eakins.net/system/files/dotplot1.png&quot;&gt;dotplot1.png&lt;/a&gt;&lt;/td&gt;&lt;td&gt;16.47 KB&lt;/td&gt; &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
</description>
 <comments>http://nolan.eakins.net/node/309#comment</comments>
 <category domain="http://nolan.eakins.net/taxonomy/term/7">Computing</category>
 <category domain="http://nolan.eakins.net/taxonomy/term/9">Programming</category>
 <enclosure url="http://nolan.eakins.net/system/files/dotplot2.png" length="1309" type="image/png" />
 <pubDate>Mon, 02 Jun 2008 21:47:24 -0700</pubDate>
 <dc:creator>sneakin</dc:creator>
 <guid isPermaLink="false">309 at http://nolan.eakins.net</guid>
</item>
<item>
 <title>eXtreme Programming Gone Wrong</title>
 <link>http://nolan.eakins.net/node/304</link>
 <description>&lt;p&gt;This is what eXtreme Programming looks like when it goes wrong with way too many index cards or in this case Post-It notes:
&lt;/p&gt;
&lt;img src=&quot;http://nolan.eakins.net/system/files/xp_gone_wrong.jpg&quot; alt=&quot;XP Gone Wrong&quot;/&gt;&lt;table id=&quot;attachments&quot;&gt;
 &lt;thead&gt;&lt;tr&gt;&lt;th&gt;Attachment&lt;/th&gt;&lt;th&gt;Size&lt;/th&gt; &lt;/tr&gt;&lt;/thead&gt;
&lt;tbody&gt;
 &lt;tr class=&quot;odd&quot;&gt;&lt;td&gt;&lt;a href=&quot;http://nolan.eakins.net/system/files/xp_gone_wrong.jpg&quot;&gt;xp_gone_wrong.jpg&lt;/a&gt;&lt;/td&gt;&lt;td&gt;90.59 KB&lt;/td&gt; &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
</description>
 <comments>http://nolan.eakins.net/node/304#comment</comments>
 <category domain="http://nolan.eakins.net/taxonomy/term/19">Humor</category>
 <category domain="http://nolan.eakins.net/taxonomy/term/9">Programming</category>
 <enclosure url="http://nolan.eakins.net/system/files/xp_gone_wrong.jpg" length="92768" type="image/jpeg" />
 <pubDate>Fri, 17 Nov 2006 06:52:37 -0800</pubDate>
 <dc:creator>sneakin</dc:creator>
 <guid isPermaLink="false">304 at http://nolan.eakins.net</guid>
</item>
<item>
 <title>Intellectual Property and oDesk</title>
 <link>http://nolan.eakins.net/node/302</link>
 <description>&lt;p&gt;
I followed the link TechCrunch posted to oDesk since I need some work. I found some job posting that I found interesting and proceeded to sign up. Low and behold the first service agreement I read just wasn&#039;t palatable. From my understanding of their &lt;a href=&quot;https://community.odesk.com/system/files?file=files/oDesk_Professional_Services_Agmt_0.pdf&quot;&gt;Professional Services Agreement&lt;/a&gt;, any pre-existing intellectual property that is incorporated into a project can essentially be used for whatever purposes oDesk wants.
&lt;/p&gt;
&lt;p&gt;
I wouldn&#039;t have an issue if this granted a license to the company that has requested the work, but it is oDesk&amp;mdash;the site that connects professionals with those that need work done. I have a body of code that&#039;s gradually getting larger that allows me to be more productive, and I like to set my own terms on its use. Sorry, I won&#039;t grant an unlimited license to it to a company whose unstated business is to hoarde IP.
&lt;/p&gt;</description>
 <comments>http://nolan.eakins.net/node/302#comment</comments>
 <category domain="http://nolan.eakins.net/taxonomy/term/10">Business</category>
 <category domain="http://nolan.eakins.net/taxonomy/term/14">Personal</category>
 <category domain="http://nolan.eakins.net/taxonomy/term/9">Programming</category>
 <pubDate>Wed, 27 Sep 2006 14:31:30 -0700</pubDate>
 <dc:creator>sneakin</dc:creator>
 <guid isPermaLink="false">302 at http://nolan.eakins.net</guid>
</item>
<item>
 <title>Super Coder</title>
 <link>http://nolan.eakins.net/node/284</link>
 <description>&lt;p&gt;Mimír just told me &lt;a href=&quot;http://it.slashdot.org/article.pl?sid=06/06/15/0252211&amp;amp;from=rss&quot;&gt;why Windows Vista will be late&lt;/a&gt;. One of the reasons is that the developers are only writing 5000 lines of code per year. This is only slightly less than the national average of 6200 lines of code.&lt;/p&gt;
&lt;p&gt;That&#039;s just shocking!&lt;/p&gt;
&lt;p&gt;My latest project, a web page to &lt;a href=&quot;http://donate.progressiveindiana.org/&quot;&gt;collect donations for a full page ad&lt;/a&gt;, took me about a month and a half to complete. It was done with &lt;a href=&quot;http://www.rubyonrails.org/&quot;&gt;RoR&lt;/a&gt; so it comes with the ability to tally up lines of code. In total I wrote 3062 lines of code. That includes actual application code, 2229, and test code, 833.&lt;/p&gt;
&lt;p&gt;I have no idea if my rate is typical, below average, or above. What I know now says that another two months of coding will cause me to cross the national lines of code average. And keeping up the rate for that last project, in one year I will have surpassed the national average by 18,292 lines of code (3062 / 1.5 * 12 - 6200).&lt;/p&gt;
&lt;p&gt;You can call me Super Coder.&lt;/p&gt;
</description>
 <comments>http://nolan.eakins.net/node/284#comment</comments>
 <category domain="http://nolan.eakins.net/taxonomy/term/9">Programming</category>
 <pubDate>Tue, 06 Jun 2006 21:29:44 -0700</pubDate>
 <dc:creator>sneakin</dc:creator>
 <guid isPermaLink="false">284 at http://nolan.eakins.net</guid>
</item>
<item>
 <title>OSS and Agility</title>
 <link>http://nolan.eakins.net/node/254</link>
 <description>&lt;p&gt;Poking around some &lt;a href=&quot;http://wiki.sourcextreme.org/index.php/Agile_Bazaar&quot;&gt;wee corners of the net&lt;/a&gt; I found my way to &lt;a href=&quot;http://64.233.187.104/search?q=cache:5jhffMtvQccJ:c2.com/cgi/wiki%3FOpenSourceAsAgileProcess+&amp;amp;hl=en&amp;amp;client=firefox-a&quot;&gt;Open Source as Agile Process&lt;/a&gt; (note: relying on GOOG since C2&#039;s wiki is down). It has a list of open source principles that meshed with agile software development.&lt;/p&gt;
&lt;p&gt;One stood out though: be open to the point of promiscuity.&lt;/p&gt;
</description>
 <comments>http://nolan.eakins.net/node/254#comment</comments>
 <category domain="http://nolan.eakins.net/taxonomy/term/9">Programming</category>
 <pubDate>Sat, 17 Dec 2005 11:47:49 -0800</pubDate>
 <dc:creator>sneakin</dc:creator>
 <guid isPermaLink="false">254 at http://nolan.eakins.net</guid>
</item>
<item>
 <title>Hit By a Train</title>
 <link>http://nolan.eakins.net/node/238</link>
 <description>&lt;p&gt;I&#039;m actually trying to produce something with Ruby on Rails, and I finally got hit by the train. Here&#039;s the problem that makes no sense at all. I have a view that does the following:&lt;/p&gt;
&lt;blockquote&gt;
&lt;pre&gt;
&lt;%= render :partial =&gt; &#039;role&#039;, :collection =&gt; @roles %&gt;
&lt;/pre&gt;&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;&lt;code&gt;@roles&lt;/code&gt; is a class attribute that&#039;s an array of roles which gets iterated over. This is where things get foobarred. In the partial I get a variable called &lt;code&gt;role&lt;/code&gt; which is good, but I want to render a text field in this partial. Rails provides me with &lt;code&gt;text_field&lt;/code&gt;. Good again because I can just enter the following to print the role&#039;s name:&lt;/p&gt;
&lt;blockquote&gt;
&lt;pre&gt;
&lt;%= text_field &quot;role&quot;, &quot;name&quot; %&gt;
&lt;/pre&gt;&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;But wait! &lt;code&gt;text_field&lt;/code&gt; will only work with class attributes for some dumb reason. Yes, that means it&#039;ll call &lt;code&gt;&lt;b&gt;@&lt;/b&gt;role.name&lt;/code&gt; to get the name, not &lt;code&gt;role.name&lt;/code&gt;. If I wanted &lt;code&gt;&lt;b&gt;@&lt;/b&gt;role&lt;/code&gt;, I would have used &lt;code&gt;&lt;b&gt;@&lt;/b&gt;role&lt;/code&gt; in my call to &lt;code&gt;text_field&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;I can not figure out why this could have been a good idea. Now I&#039;m stuck contemplating whether I should hack up my own &lt;code&gt;text_field&lt;/code&gt; that works logically or not.&lt;/p&gt;
&lt;p&gt;&lt;!--break--&gt;&lt;/p&gt;
</description>
 <comments>http://nolan.eakins.net/node/238#comment</comments>
 <category domain="http://nolan.eakins.net/taxonomy/term/9">Programming</category>
 <category domain="http://nolan.eakins.net/taxonomy/term/26">Web</category>
 <pubDate>Thu, 03 Nov 2005 02:25:32 -0800</pubDate>
 <dc:creator>sneakin</dc:creator>
 <guid isPermaLink="false">238 at http://nolan.eakins.net</guid>
</item>
<item>
 <title>Long Live Static Typing!</title>
 <link>http://nolan.eakins.net/node/212</link>
 <description>&lt;p&gt;I just read an article that mentioned dynamic and statically typed languages, and I also just looked up Ruby&#039;s &lt;code&gt;yield&lt;/code&gt; statement. One of the examples on &lt;a href=&quot;http://www.rubycentral.com/book/tut_containers.html&quot;&gt;the page I found&lt;/a&gt; was this:&lt;/p&gt;
&lt;pre&gt;
class SongList
  def [](key)
    if key.kind_of?(Integer)
      @songs[key]
    else
      # ...
    end
  end
end
&lt;/pre&gt;&lt;p&gt;The problem I have is with the &lt;code&gt;if key.kind_of?(Integer)&lt;/code&gt;. I&#039;ve been toying with Lisp some, and it reintroduces static typing (think C/C++ function/method arguments). So the above could be simplified a lot, especially if a method needed to be specialized for a ton of types. This could be done by specifying an argument&#039;s type. The following would work perfect, and could allow some optimizations to be made too:&lt;/p&gt;
&lt;pre&gt;
class SongList
  def [](Integer key)
    @songs[key]
  end

  def [](key)
    # ...
  end
end
&lt;/pre&gt;&lt;br /&gt;
</description>
 <comments>http://nolan.eakins.net/node/212#comment</comments>
 <category domain="http://nolan.eakins.net/taxonomy/term/9">Programming</category>
 <pubDate>Fri, 09 Sep 2005 23:58:37 -0700</pubDate>
 <dc:creator>sneakin</dc:creator>
 <guid isPermaLink="false">212 at http://nolan.eakins.net</guid>
</item>
<item>
 <title>Ruby Style Continuations In Lisp</title>
 <link>http://nolan.eakins.net/node/199</link>
 <description>&lt;p&gt;A few days ago I found out Ruby supported continuations. I started playing with them in an experiment to be detailed later. One of the things Ruby has over Lisp is an understandable syntax for them. In Lisp all I had was &lt;a href=&quot;http://www.paulgraham.com/&quot;&gt;Paul Graham&#039;s&lt;/a&gt; continuation code from his Lisp book:&lt;/p&gt;
&lt;blockquote&gt;
&lt;pre&gt;
(setq *cont* #&#039;identity)

(defmacro =lambda (params &amp;body body)
  `#&#039;(lambda (*cont* ,@params) ,@body))

(defmacro =defun (name params &amp;body body)
  (let ((f (intern (concatenate &#039;string
				&quot;=&quot; (symbol-name name)))))
    `(progn
      (defmacro ,name ,params
	`(,&#039;,f *cont* ,,@params))
      (defun ,f (*cont* ,@params) ,@body))))

(defmacro =bind (params expr &amp;body body)
  `(let ((*cont* #&#039;(lambda ,params ,@body))) ,expr))

(defmacro =values (&amp;rest retvals)
  `(funcall *cont* ,@retvals))

(defmacro =funcall (fn &amp;rest args)
  `(funcall ,fn *cont* ,@args))

(defmacro =apply (fn &amp;rest args)
  `(apply ,fn *cont* ,@args))
&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;p&gt;PG also provided some examples using that. One of them was a depth first traversal. It creates the continuation when it pushes a lambda. The syntax basically offers no help in understanding how to use it as you can see:&lt;/p&gt;
&lt;blockquote&gt;
&lt;pre&gt;
(setq *saved* nil)

(=defun dft-node (tree)
  (cond ((null tree) (dft-restart))
	((atom tree) (=values tree))
	(t (push #&#039;(lambda () (dft-node (cdr tree)))
		 *saved*)
	   (dft-node (car tree)))))

(=defun dft-restart ()
  (if *saved*
      (funcall (pop *saved*))
      (=values &#039;done)))

(=defun dft2 (tree)
  (setq *saved* nil)
  (=bind (node) (dft-node tree)
    (cond ((eq node &#039;done) (=values nil))
	  (t (princ node)
	     (dft-restart)))))
&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;p&gt;Even with that example, I still couldn&#039;t wrap my head around it until I started playing with Ruby&#039;s. Ruby has a &lt;code&gt;callcc&lt;/code&gt; keyword that creates a continuation. It&#039;s syntax is basically:&lt;/p&gt;
&lt;blockquote&gt;
&lt;pre&gt;
callcc do |cc|
   # Do some stuff
end
# Do some other stuff when we call &#039;cc&#039; above
&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;p&gt;That syntax makes it pretty easy to understand how to use them which is all that matters. PG&#039;s example code offered nothing in that direction, so I recreated PG&#039;s DFT example in Ruby and got the following:&lt;/p&gt;
&lt;blockquote&gt;
&lt;pre&gt;
$conts = Array.new

def dft_restart()
  if $conts.length &gt; 0
    $conts.pop.call
    return nil
  end
end

def dft_node(tree)
  if tree == nil
    dft_restart
  elsif tree.class != Array
    return tree
  else
    callcc do |cc|
      $conts.push cc
      return dft_node(tree[0])
    end
    return dft_node(tree[1, tree.length])
  end
end    

def dft2 tree
  $conts = Array.new
  node = dft_node tree
  if node != nil
    puts node
    dft_restart
  end
end
&lt;/pre&gt;
&lt;/blockquote&gt;
Ruby&#039;s &lt;code&gt;callcc&lt;/code&gt; helped me understand exactly what was going on. So I started messing around and created a macro that creates Ruby&#039;s &lt;code&gt;callcc&lt;/code&gt; in Lisp. This is the macro:&lt;/p&gt;
&lt;blockquote&gt;
&lt;pre&gt;
;; Ruby style syntax
(defun search-replace (list key value)
  &quot;Replace all instances of KEY found in LIST with VALUE.&quot;
  (cond ((null list) nil)
	((symbolp list) (if (eq list key) value list))
	((atom list) list)
	(t (cons (search-replace (car list) key value)
		 (search-replace (cdr list) key value)))))

(defmacro callcc (inner &amp;body body)
  (let ((var-name (first inner))
	(var-exp `#&#039;(lambda () ,@body)))
    `(progn ,@(search-replace (cdr inner) var-name var-exp))))
&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;p&gt;The syntax for that is essentially like Ruby&#039;s:&lt;/p&gt;
&lt;blockquote&gt;
&lt;pre&gt;
(callcc (cc &lt;i&gt;do some stuff&lt;/i&gt;)
   &lt;i&gt;Do some more stuff when we call &#039;cc&#039;&lt;/i&gt;)
&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;p&gt;The &lt;code&gt;cc&lt;/code&gt; variable name can be changed to whatever, and it represents the continuation that you can save to call later. So back in Lisp PG&#039;s DFT-NODE then becomes:&lt;/p&gt;
&lt;blockquote&gt;
&lt;pre&gt;
(=defun dft-node (tree)
  (cond ((null tree) (dft-restart))
	((atom tree) (=values tree))
	(t (callcc (cc
		    (push cc *saved*)
		    (dft-node (car tree)))
 	      (dft-node (cdr tree))))))
&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;p&gt;To me anyway that makes more sense because the voodoo isn&#039;t up front. It&#039;s tucked into the &lt;code&gt;callcc&lt;/code&gt;. To you innocent bystanders, it probably still makes no sense, but now you have some code to play with.&lt;/p&gt;
&lt;!--break--&gt;</description>
 <comments>http://nolan.eakins.net/node/199#comment</comments>
 <category domain="http://nolan.eakins.net/taxonomy/term/23">Lisp</category>
 <category domain="http://nolan.eakins.net/taxonomy/term/9">Programming</category>
 <pubDate>Sat, 13 Aug 2005 15:52:30 -0700</pubDate>
 <dc:creator>sneakin</dc:creator>
 <guid isPermaLink="false">199 at http://nolan.eakins.net</guid>
</item>
</channel>
</rss>
