<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Artful Code &#187; releases</title>
	<atom:link href="http://www.artfulcode.net/tags/releases/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.artfulcode.net</link>
	<description>Resources and tips for dynamic, interactive languages.</description>
	<lastBuildDate>Fri, 09 Sep 2011 02:15:45 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>An alternative to large multi-selects</title>
		<link>http://www.artfulcode.net/articles/alternative-large-multi-selects/</link>
		<comments>http://www.artfulcode.net/articles/alternative-large-multi-selects/#comments</comments>
		<pubDate>Fri, 12 Sep 2008 15:15:59 +0000</pubDate>
		<dc:creator>Jeff</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[releases]]></category>

		<guid isPermaLink="false">http://www.artfulcode.net/articles/alternative-large-multi-selects/</guid>
		<description><![CDATA[HTML has no useful, built-in form widget for selecting from a large number of options. Some libraries offer Javascript-powered alternatives, but few of these are built to deal with more than a few hundred options. The problem I recently worked on a project with a backend using the Django admin library. It is a wonderful [...]]]></description>
			<content:encoded><![CDATA[<p>HTML has no useful, built-in form widget for selecting from a large number of options.  Some libraries offer Javascript-powered alternatives, but few of these are built to deal with more than a few hundred options.<span id="more-12"></span></p>
<h4>The problem</h4>
<p>I recently worked on a project with a backend using the Django admin library.  It is a wonderful tool, but the <a href="http://docs.djangoproject.com/en/dev/ref/contrib/admin/#filter-horizontal">filter interface</a> is not equipped to deal with the thousands of options that were being populated in this particular form entry (a necessary parameter of the project.)</p>
<p>The Django filter interface would take 30 seconds or more to load the multi-select&#8217;s data on each form load, even on speedy computers.  Moreover, the search filter breaks up queries at spaces, then performs a substring search for each token for every option in the select.  Suffice it to say that this locked up more than a few browsers in our testing.</p>
<h4>The solution</h4>
<p>My first thought was to create my own search using a ternary tree or trie to index the data, but building these structures turned out to be <em>extremely</em> slow implemented in Javascript, taking even more time than the Django filter to initialize.</p>
<p>I ended up trying what seemed like a foolish idea.  Create one large string to search by joining all of the options&#8217; labels together (and delimiting with pipes).  I assumed this would take a huge amount of memory, but in fact it took less than Javascript trees and was <em>much</em> faster than operating directly on DOM nodes.  By delimiting the strings, a bounded regular expression could be used to perform reasonably fast searches of the data.  There would be the need to identify the options to which the strings originated, for which I created a simple hash mapping option label to value.</p>
<p>This solution has two main problems &#8211; it assumes that all entries in the select box have <em>both</em> a unique label and a unique value, and no label can have a pipe in it.  However, assuming that these conditions are met, this solution seems to work pretty speedily, and without overtaxing the browser.</p>
<h4>The code</h4>
<p>This code is implemented as a <a href="http://www.jquery.com">jQuery</a> plugin.  It hides the select and changes made to the widget automatically update the select.  A search box and two lists are inserted into the document; the user enters a partial match in the search box and hits return.  The first list is populated with the search results.  Double-clicking on a result copies it into the second list.</p>
<p>Items that are already selected are automatically put into the second list.  Regular expressions are permitted, and must be surrounded by forward slashes.</p>
<p>This module has been lightly tested in Firefox 2 and 3, Safari (latest), Opera (latest), and IE 7.  A few concessions in favor of efficiency have been made at the expense of clarity (mainly for IE, which seems to have the slowest Javascript engine), primarily in the SelectMap constructor.  jQuery&#8217;s each method and string concatenation proved to be too much for IE, so they were replaced with a for loop over the select node&#8217;s legacy <code>options</code> array.  Iterative string building was replaced with <code>Array.join</code>, which is faster (but more expensive in memory) in IE.</p>
<p>To use it:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #003366; font-weight: bold;">var</span> select <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> BigSelect<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'target_id'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #006600; font-style: italic;">// or...</span>
    $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#target_id'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">bigSelect</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>The code is available <a title="Artful Code Projects" href="http://www.artfulcode.net/projects/">here</a>.  <span style="text-decoration: line-through;">You can see a live example here.</span></p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a><strong><em>Submit article</em></strong></a>
<br />
<div class="d">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http%3A%2F%2Fwww.artfulcode.net%2Farticles%2Falternative-large-multi-selects%2F&amp;title=An+alternative+to+large+multi-selects" rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://www.artfulcode.net/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.artfulcode.net%2Farticles%2Falternative-large-multi-selects%2F&amp;title=An+alternative+to+large+multi-selects" rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://www.artfulcode.net/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.dzone.com/links/add.html?description=An+alternative+to+large+multi-selects&amp;url=http%3A%2F%2Fwww.artfulcode.net%2Farticles%2Falternative-large-multi-selects%2F&amp;title=An+alternative+to+large+multi-selects" rel="nofollow" title="Add to&nbsp;DZone"><img class="social_img" src="http://www.artfulcode.net/wp-content/plugins/social-bookmarks/images/dzone.png" title="Add to&nbsp;DZone" alt="Add to&nbsp;DZone" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http%3A%2F%2Fwww.artfulcode.net%2Farticles%2Falternative-large-multi-selects%2F" rel="nofollow" title="Add to&nbsp;Facebook"><img class="social_img" src="http://www.artfulcode.net/wp-content/plugins/social-bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http%3A%2F%2Fwww.artfulcode.net%2Farticles%2Falternative-large-multi-selects%2F&amp;title=An+alternative+to+large+multi-selects" rel="nofollow" title="Add to&nbsp;reddit"><img class="social_img" src="http://www.artfulcode.net/wp-content/plugins/social-bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.artfulcode.net%2Farticles%2Falternative-large-multi-selects%2F&amp;title=An+alternative+to+large+multi-selects" rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://www.artfulcode.net/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http%3A%2F%2Fwww.artfulcode.net%2Farticles%2Falternative-large-multi-selects%2F" rel="nofollow" title="Add to&nbsp;Technorati"><img class="social_img" src="http://www.artfulcode.net/wp-content/plugins/social-bookmarks/images/technorati.png" title="Add to&nbsp;Technorati" alt="Add to&nbsp;Technorati" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://twitter.com/home/?status=Check+out+An+alternative+to+large+multi-selects+@+http%3A%2F%2Fwww.artfulcode.net%2Farticles%2Falternative-large-multi-selects%2F" rel="nofollow" title="Add to&nbsp;Twitter"><img class="social_img" src="http://www.artfulcode.net/wp-content/plugins/social-bookmarks/images/twitter.png" title="Add to&nbsp;Twitter" alt="Add to&nbsp;Twitter" /></a>
<br />
</div>
</div>
<!-- Social Bookmarks END -->
]]></content:encoded>
			<wfw:commentRss>http://www.artfulcode.net/articles/alternative-large-multi-selects/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>newLISP TextMate bundle 1.1</title>
		<link>http://www.artfulcode.net/articles/newlisp-textmate-bundle-11/</link>
		<comments>http://www.artfulcode.net/articles/newlisp-textmate-bundle-11/#comments</comments>
		<pubDate>Tue, 19 Aug 2008 17:49:05 +0000</pubDate>
		<dc:creator>Jeff</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[releases]]></category>

		<guid isPermaLink="false">http://www.artfulcode.net/articles/newlisp-textmate-bundle-11/</guid>
		<description><![CDATA[Not a whole lot new with this release. A new theme (newLISP dark) with a dark background and a couple of updates to recognized keywords. Download it here. Submit article]]></description>
			<content:encoded><![CDATA[<p>Not a whole lot new with this release.  A new theme (newLISP dark) with a dark background and a couple of updates to recognized keywords.  Download it <a href="/projects/">here</a>.</p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a><strong><em>Submit article</em></strong></a>
<br />
<div class="d">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http%3A%2F%2Fwww.artfulcode.net%2Farticles%2Fnewlisp-textmate-bundle-11%2F&amp;title=newLISP+TextMate+bundle+1.1" rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://www.artfulcode.net/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.artfulcode.net%2Farticles%2Fnewlisp-textmate-bundle-11%2F&amp;title=newLISP+TextMate+bundle+1.1" rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://www.artfulcode.net/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.dzone.com/links/add.html?description=newLISP+TextMate+bundle+1.1&amp;url=http%3A%2F%2Fwww.artfulcode.net%2Farticles%2Fnewlisp-textmate-bundle-11%2F&amp;title=newLISP+TextMate+bundle+1.1" rel="nofollow" title="Add to&nbsp;DZone"><img class="social_img" src="http://www.artfulcode.net/wp-content/plugins/social-bookmarks/images/dzone.png" title="Add to&nbsp;DZone" alt="Add to&nbsp;DZone" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http%3A%2F%2Fwww.artfulcode.net%2Farticles%2Fnewlisp-textmate-bundle-11%2F" rel="nofollow" title="Add to&nbsp;Facebook"><img class="social_img" src="http://www.artfulcode.net/wp-content/plugins/social-bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http%3A%2F%2Fwww.artfulcode.net%2Farticles%2Fnewlisp-textmate-bundle-11%2F&amp;title=newLISP+TextMate+bundle+1.1" rel="nofollow" title="Add to&nbsp;reddit"><img class="social_img" src="http://www.artfulcode.net/wp-content/plugins/social-bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.artfulcode.net%2Farticles%2Fnewlisp-textmate-bundle-11%2F&amp;title=newLISP+TextMate+bundle+1.1" rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://www.artfulcode.net/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http%3A%2F%2Fwww.artfulcode.net%2Farticles%2Fnewlisp-textmate-bundle-11%2F" rel="nofollow" title="Add to&nbsp;Technorati"><img class="social_img" src="http://www.artfulcode.net/wp-content/plugins/social-bookmarks/images/technorati.png" title="Add to&nbsp;Technorati" alt="Add to&nbsp;Technorati" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://twitter.com/home/?status=Check+out+newLISP+TextMate+bundle+1.1+@+http%3A%2F%2Fwww.artfulcode.net%2Farticles%2Fnewlisp-textmate-bundle-11%2F" rel="nofollow" title="Add to&nbsp;Twitter"><img class="social_img" src="http://www.artfulcode.net/wp-content/plugins/social-bookmarks/images/twitter.png" title="Add to&nbsp;Twitter" alt="Add to&nbsp;Twitter" /></a>
<br />
</div>
</div>
<!-- Social Bookmarks END -->
]]></content:encoded>
			<wfw:commentRss>http://www.artfulcode.net/articles/newlisp-textmate-bundle-11/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SQL library for newLISP</title>
		<link>http://www.artfulcode.net/articles/sql-library-newlisp/</link>
		<comments>http://www.artfulcode.net/articles/sql-library-newlisp/#comments</comments>
		<pubDate>Mon, 14 Jul 2008 21:24:35 +0000</pubDate>
		<dc:creator>Jeff</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[foop]]></category>
		<category><![CDATA[functional]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[newlisp]]></category>
		<category><![CDATA[releases]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://www.artfulcode.net/articles/sql-library-newlisp/</guid>
		<description><![CDATA[The newLISP SQL library is a set of classes and functions to ease generation of SQL code in newLISP. The module is not yet feature-complete but is in a usable state. Much of the module uses the small convenience classes to &#8220;serialize&#8221; SQL expressions. Most of the module&#8217;s classes have :serialize methods that render the [...]]]></description>
			<content:encoded><![CDATA[<p>The newLISP SQL library is a set of classes and functions to ease generation of SQL code in newLISP.  The module is not yet feature-complete but is in a usable state.<span id="more-20"></span></p>
<p>Much of the module uses the small convenience classes to &#8220;serialize&#8221; SQL expressions.  Most of the module&#8217;s classes have <code>:serialize</code> methods that render the encapsulated data as a string.  For example, the <code>Field</code> class:</p>

<div class="wp_syntax"><div class="code"><pre class="lisp" style="font-family:monospace;"><span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">let</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>f <span style="color: #66cc66;">&#40;</span>Field <span style="color: #ff0000;">&quot;table&quot;</span> <span style="color: #ff0000;">&quot;fieldname&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
    <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">:</span><span style="color: #555;">serialize</span> f<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">=&amp;</span>gt<span style="color: #808080; font-style: italic;">; &quot;table.fieldname&quot;</span></pre></div></div>

<p>&#8230;or the <code>Condition</code> class:</p>

<div class="wp_syntax"><div class="code"><pre class="lisp" style="font-family:monospace;"><span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">let</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>c <span style="color: #66cc66;">&#40;</span>Condition <span style="color: #ff0000;">&quot;&amp;gt;&quot;</span> <span style="color: #ff0000;">&quot;salary&quot;</span> <span style="color: #cc66cc;">65000</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
    <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">:</span><span style="color: #555;">serialize</span> c<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">=&amp;</span>gt<span style="color: #808080; font-style: italic;">; &quot;salary &amp;gt; '65000'&quot;</span></pre></div></div>

<p>Note that values are enclosed in single quotes for ANSI compliance.  The most interesting function in the module, however, is <code>sql:expr</code>, which uses the <code>match</code>-based primitives in the <span style="text-decoration: line-through;">functional</span> module to generate various types of expressions:</p>

<div class="wp_syntax"><div class="code"><pre class="lisp" style="font-family:monospace;"><span style="color: #66cc66;">&#40;</span>sql<span style="color: #66cc66;">:</span><span style="color: #555;">expr</span> <span style="color: #ff0000;">&quot;employees&quot;</span> <span style="color: #ff0000;">&quot;first_name&quot;</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">=&amp;</span>gt<span style="color: #808080; font-style: italic;">; &quot;employees.first_name&quot;</span>
&nbsp;
<span style="color: #66cc66;">&#40;</span>sql<span style="color: #66cc66;">:</span><span style="color: #555;">expr</span> <span style="color: #ff0000;">&quot;LIKE&quot;</span> <span style="color: #ff0000;">&quot;first_name&quot;</span> <span style="color: #ff0000;">&quot;Stev%&quot;</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">=&amp;</span>gt<span style="color: #808080; font-style: italic;">; &quot;first_name LIKE 'Stev%'&quot;</span>
&nbsp;
<span style="color: #66cc66;">&#40;</span>sql<span style="color: #66cc66;">:</span><span style="color: #555;">expr</span> <span style="color: #ff0000;">&quot;OR&quot;</span> <span style="color: #66cc66;">&#40;</span>sql<span style="color: #66cc66;">:</span><span style="color: #555;">expr</span> <span style="color: #ff0000;">&quot;LIKE&quot;</span> <span style="color: #ff0000;">&quot;first_name&quot;</span> <span style="color: #ff0000;">&quot;Stev%&quot;</span><span style="color: #66cc66;">&#41;</span>
               <span style="color: #66cc66;">&#40;</span>sql<span style="color: #66cc66;">:</span><span style="color: #555;">expr</span> <span style="color: #ff0000;">&quot;LIKE&quot;</span> <span style="color: #ff0000;">&quot;last_name&quot;</span> <span style="color: #ff0000;">&quot;John%&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">=&amp;</span>gt<span style="color: #808080; font-style: italic;">; &quot;((first_name LIKE 'Stev%') OR (last_name LIKE 'John%'))&quot;</span>
&nbsp;
<span style="color: #66cc66;">&#40;</span>sql<span style="color: #66cc66;">:</span><span style="color: #555;">expr</span> <span style="color: #cc66cc;">6</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">=&amp;</span>gt<span style="color: #808080; font-style: italic;">;&quot;6&quot;</span>
&nbsp;
<span style="color: #66cc66;">&#40;</span>sql<span style="color: #66cc66;">:</span><span style="color: #555;">expr</span> 'myapp<span style="color: #66cc66;">:</span><span style="color: #555;">employees</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">=&amp;</span>gt<span style="color: #808080; font-style: italic;">; &quot;employees&quot;</span>
&nbsp;
<span style="color: #66cc66;">&#40;</span>sql<span style="color: #66cc66;">:</span><span style="color: #555;">expr</span> <span style="color: #ff0000;">&quot;CONV&quot;</span> <span style="color: #ff0000;">&quot;AF&quot;</span> <span style="color: #cc66cc;">16</span> <span style="color: #cc66cc;">10</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">=&amp;</span>gt<span style="color: #808080; font-style: italic;">; &quot;CONV('AF',16,10)&quot;</span>
&nbsp;
<span style="color: #66cc66;">&#40;</span>sql<span style="color: #66cc66;">:</span><span style="color: #555;">expr</span> <span style="color: #ff0000;">&quot;LIKE&quot;</span> <span style="color: #66cc66;">&#40;</span>sql<span style="color: #66cc66;">:</span><span style="color: #555;">expr</span> <span style="color: #ff0000;">&quot;employees&quot;</span> <span style="color: #ff0000;">&quot;first_name&quot;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #ff0000;">&quot;Stev%&quot;</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">=&amp;</span>gt<span style="color: #808080; font-style: italic;">; &quot;employees.first_name LIKE 'Stev%'&quot;</span></pre></div></div>

<p>Additional functions directly express <code>select</code>, <code>update</code>, <code>insert</code>, and <code>delete</code> statements or handle data type conversions (such as parsing SQL datetimes).</p>
<h4>Functional</h4>
<p>Another addition to Artful Code&#8217;s module list is the <span style="text-decoration: line-through;">functional</span> module.  This library provides some basic conditionals that make use of <code>match</code> to process data.  These macros express program logic by associating blocks of code with the structure of data.</p>
<p>Here is an example using <code>match-case</code>. <code>match-case</code> accepts a single expression and a series of forms that describe what to do based on its structure.  Each case form consists of a <a href="http://www.newlisp.org/downloads/newlisp_manual.html#match">match expression</a>, a list of variables to be locally bound to the result of the match, and an individual form to evaluate in a local scope with the matched variables bound:</p>

<div class="wp_syntax"><div class="code"><pre class="lisp" style="font-family:monospace;"><span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">let</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>x '<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span> <span style="color: #cc66cc;">2</span> <span style="color: #cc66cc;">3</span> <span style="color: #cc66cc;">4</span> <span style="color: #cc66cc;">5</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
    <span style="color: #66cc66;">&#40;</span>match-<span style="color: #b1b100;">case</span> x
        <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>? ? ?<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#40;</span>a b c<span style="color: #66cc66;">&#41;</span>
         <span style="color: #66cc66;">&#40;</span>println <span style="color: #ff0000;">&quot;a b and c do not get bound here, because they do not match x&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
        <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>? ? ? *<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#40;</span>a b c d<span style="color: #66cc66;">&#41;</span>
         <span style="color: #66cc66;">&#40;</span>println <span style="color: #ff0000;">&quot;a = 1, b = 2, c = 3, and d = '(4 5)&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span></pre></div></div>

<p>Here, the second block would match because <code>(? ? ? *)</code> matches against <code>(1 2 3 4 5)</code> and creates the binding association, <code>((a 1) (b 2) (c 3) (d (4 5)))</code>.</p>
<p>Also included in the module is <code>match-cond</code>, which is more powerful than <code>match-case</code>. <code>match-cond</code> works like <code>cond</code>, except that instead of a user-defined conditional, the first form in each case is a list of <code>pattern</code>, <code>symbol-list</code>, and <code>target</code>.  See the <span style="text-decoration: line-through;">documentation</span> for more details.</p>
<p><strong>Edit (2009-02-16): the functional module in mentioned in this post has been replaced with the <a href="http://static.artfulcode.net/newlisp/matching.lsp.html">matching</a> module.</strong></p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a><strong><em>Submit article</em></strong></a>
<br />
<div class="d">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http%3A%2F%2Fwww.artfulcode.net%2Farticles%2Fsql-library-newlisp%2F&amp;title=SQL+library+for+newLISP" rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://www.artfulcode.net/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.artfulcode.net%2Farticles%2Fsql-library-newlisp%2F&amp;title=SQL+library+for+newLISP" rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://www.artfulcode.net/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.dzone.com/links/add.html?description=SQL+library+for+newLISP&amp;url=http%3A%2F%2Fwww.artfulcode.net%2Farticles%2Fsql-library-newlisp%2F&amp;title=SQL+library+for+newLISP" rel="nofollow" title="Add to&nbsp;DZone"><img class="social_img" src="http://www.artfulcode.net/wp-content/plugins/social-bookmarks/images/dzone.png" title="Add to&nbsp;DZone" alt="Add to&nbsp;DZone" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http%3A%2F%2Fwww.artfulcode.net%2Farticles%2Fsql-library-newlisp%2F" rel="nofollow" title="Add to&nbsp;Facebook"><img class="social_img" src="http://www.artfulcode.net/wp-content/plugins/social-bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http%3A%2F%2Fwww.artfulcode.net%2Farticles%2Fsql-library-newlisp%2F&amp;title=SQL+library+for+newLISP" rel="nofollow" title="Add to&nbsp;reddit"><img class="social_img" src="http://www.artfulcode.net/wp-content/plugins/social-bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.artfulcode.net%2Farticles%2Fsql-library-newlisp%2F&amp;title=SQL+library+for+newLISP" rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://www.artfulcode.net/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http%3A%2F%2Fwww.artfulcode.net%2Farticles%2Fsql-library-newlisp%2F" rel="nofollow" title="Add to&nbsp;Technorati"><img class="social_img" src="http://www.artfulcode.net/wp-content/plugins/social-bookmarks/images/technorati.png" title="Add to&nbsp;Technorati" alt="Add to&nbsp;Technorati" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://twitter.com/home/?status=Check+out+SQL+library+for+newLISP+@+http%3A%2F%2Fwww.artfulcode.net%2Farticles%2Fsql-library-newlisp%2F" rel="nofollow" title="Add to&nbsp;Twitter"><img class="social_img" src="http://www.artfulcode.net/wp-content/plugins/social-bookmarks/images/twitter.png" title="Add to&nbsp;Twitter" alt="Add to&nbsp;Twitter" /></a>
<br />
</div>
</div>
<!-- Social Bookmarks END -->
]]></content:encoded>
			<wfw:commentRss>http://www.artfulcode.net/articles/sql-library-newlisp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>newLISP modules section</title>
		<link>http://www.artfulcode.net/articles/newlisp-modules-section/</link>
		<comments>http://www.artfulcode.net/articles/newlisp-modules-section/#comments</comments>
		<pubDate>Tue, 08 Jul 2008 19:49:06 +0000</pubDate>
		<dc:creator>Jeff</dc:creator>
				<category><![CDATA[Site news]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[newlisp]]></category>
		<category><![CDATA[releases]]></category>

		<guid isPermaLink="false">http://www.artfulcode.net/articles/newlisp-modules-section/</guid>
		<description><![CDATA[I have added a new area to the site specifically for newLISP modules. I am in the process of documenting all of my libraries and adding them to that page. A couple of notable modules: CSV &#8211; a module for parsing CSV files Mysql &#8211; a wrapper for the standard MySQL module, with some helpful [...]]]></description>
			<content:encoded><![CDATA[<p>I have added a new area to the site specifically for <a href="http://static.artfulcode.net/newlisp/">newLISP modules</a>.  I am in the process of documenting all of my libraries and adding them to that page.  A couple of notable modules:</p>
<ol>
<li> <a href="http://static.artfulcode.net/newlisp/csv.lsp.html">CSV</a> &#8211; a module for parsing CSV files</li>
<li> <a href="http://static.artfulcode.net/newlisp/mysql.lsp.html">Mysql</a> &#8211; a wrapper for the standard MySQL module, with some helpful additions</li>
<li> <a href="http://static.artfulcode.net/newlisp/http.lsp.html">Http</a> &#8211; a simple, bare-bones HTTP 1.0 library</li>
<li> <span style="text-decoration: line-through;">SocketServer</span><span style="text-decoration: line-through;"> &#8211; an extensible socket server framework</span></li>
<li> <a href="http://static.artfulcode.net/newlisp/xmlrpc-server.lsp.html">Xmlrpc-server</a> &#8211; an XML-RPC server using SocketServer and Http</li>
<li> <a href="http://static.artfulcode.net/newlisp/old/generics.lsp.html">generics</a> &#8211; generic functions for newLISP in the style of CLOS</li>
<li> <span style="text-decoration: line-through;">locks</span><span style="text-decoration: line-through;"> &#8211; FOOP classes for process synchronization</span></li>
</ol>
<p>There is also <a href="http://static.artfulcode.net/newlisp/util.lsp.html">a utilities library</a>, which contains functions and classes required by the other libraries.</p>
<p>newLISP 9.4.2 is required for several of these (util.lsp requires 9.4.2 due to a dictionary syntax bug in 9.4.1).</p>
<p>Update (2008-07-09): I&#8217;ve moved a few modules from the projects page to the modules page, most notably the request, response, and xml modules.</p>
<p>Update (2009-02-10): Several of these modules have disappeared (SocketServer and locks) and have been replaced. The new modules are <a href="http://static.artfulcode.net/newlisp/sockets.lsp.html">sockets</a>, which is more generalized and powerful than SocketServer was, and <a href="http://static.artfulcode.net/newlisp/mp.lsp.html">MP</a>,  which is a full-featured multi-processing module.</p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a><strong><em>Submit article</em></strong></a>
<br />
<div class="d">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http%3A%2F%2Fwww.artfulcode.net%2Farticles%2Fnewlisp-modules-section%2F&amp;title=newLISP+modules+section" rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://www.artfulcode.net/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.artfulcode.net%2Farticles%2Fnewlisp-modules-section%2F&amp;title=newLISP+modules+section" rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://www.artfulcode.net/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.dzone.com/links/add.html?description=newLISP+modules+section&amp;url=http%3A%2F%2Fwww.artfulcode.net%2Farticles%2Fnewlisp-modules-section%2F&amp;title=newLISP+modules+section" rel="nofollow" title="Add to&nbsp;DZone"><img class="social_img" src="http://www.artfulcode.net/wp-content/plugins/social-bookmarks/images/dzone.png" title="Add to&nbsp;DZone" alt="Add to&nbsp;DZone" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http%3A%2F%2Fwww.artfulcode.net%2Farticles%2Fnewlisp-modules-section%2F" rel="nofollow" title="Add to&nbsp;Facebook"><img class="social_img" src="http://www.artfulcode.net/wp-content/plugins/social-bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http%3A%2F%2Fwww.artfulcode.net%2Farticles%2Fnewlisp-modules-section%2F&amp;title=newLISP+modules+section" rel="nofollow" title="Add to&nbsp;reddit"><img class="social_img" src="http://www.artfulcode.net/wp-content/plugins/social-bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.artfulcode.net%2Farticles%2Fnewlisp-modules-section%2F&amp;title=newLISP+modules+section" rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://www.artfulcode.net/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http%3A%2F%2Fwww.artfulcode.net%2Farticles%2Fnewlisp-modules-section%2F" rel="nofollow" title="Add to&nbsp;Technorati"><img class="social_img" src="http://www.artfulcode.net/wp-content/plugins/social-bookmarks/images/technorati.png" title="Add to&nbsp;Technorati" alt="Add to&nbsp;Technorati" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://twitter.com/home/?status=Check+out+newLISP+modules+section+@+http%3A%2F%2Fwww.artfulcode.net%2Farticles%2Fnewlisp-modules-section%2F" rel="nofollow" title="Add to&nbsp;Twitter"><img class="social_img" src="http://www.artfulcode.net/wp-content/plugins/social-bookmarks/images/twitter.png" title="Add to&nbsp;Twitter" alt="Add to&nbsp;Twitter" /></a>
<br />
</div>
</div>
<!-- Social Bookmarks END -->
]]></content:encoded>
			<wfw:commentRss>http://www.artfulcode.net/articles/newlisp-modules-section/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Request and Response modules for newLISP</title>
		<link>http://www.artfulcode.net/articles/request-and-response-modules-newlisp/</link>
		<comments>http://www.artfulcode.net/articles/request-and-response-modules-newlisp/#comments</comments>
		<pubDate>Fri, 22 Feb 2008 20:18:50 +0000</pubDate>
		<dc:creator>Jeff</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[newlisp]]></category>
		<category><![CDATA[releases]]></category>

		<guid isPermaLink="false">http://www.artfulcode.net/articles/request-and-response-modules-newlisp/</guid>
		<description><![CDATA[Together, these two modules form a coherent replacement for the newLISP CGI module. They can be found here. The Request module parses GET, POST, and COOKIE data and provides a few simple functions to retrieve these values. Values may be looked up by key using: &#40;Request:get &#34;foo&#34;&#41; &#40;Request:post &#34;foo&#34;&#41; &#40;Request:cookie &#34;foo&#34;&#41; POST data is restricted [...]]]></description>
			<content:encoded><![CDATA[<p>Together, these two modules form a coherent replacement for the <a href="http://www.newlisp.org/code/modules/cgi.lsp.html">newLISP CGI module</a>.  They can be found <a href="http://static.artfulcode.net/newlisp/">here</a>.<span id="more-33"></span></p>
<p>The Request module parses GET, POST, and COOKIE data and provides a few simple functions to retrieve these values.  Values may be looked up by key using:</p>

<div class="wp_syntax"><div class="code"><pre class="lisp" style="font-family:monospace;"><span style="color: #66cc66;">&#40;</span>Request<span style="color: #66cc66;">:</span><span style="color: #b1b100;">get</span> <span style="color: #ff0000;">&quot;foo&quot;</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#40;</span>Request<span style="color: #66cc66;">:</span><span style="color: #555;">post</span> <span style="color: #ff0000;">&quot;foo&quot;</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#40;</span>Request<span style="color: #66cc66;">:</span><span style="color: #555;">cookie</span> <span style="color: #ff0000;">&quot;foo&quot;</span><span style="color: #66cc66;">&#41;</span></pre></div></div>

<p>POST data is restricted to 4096 bytes.  This can be altered by editing the <code>*max-post-length*</code> constant.  I have included a few useful predicates:</p>

<div class="wp_syntax"><div class="code"><pre class="lisp" style="font-family:monospace;"><span style="color: #66cc66;">&#40;</span>Request<span style="color: #66cc66;">:</span><span style="color: #b1b100;">get</span>?<span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#40;</span>Request<span style="color: #66cc66;">:</span><span style="color: #555;">post</span>?<span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#40;</span>Request<span style="color: #66cc66;">:</span><span style="color: #555;">cookie</span>? <span style="color: #ff0000;">&quot;foo&quot;</span><span style="color: #66cc66;">&#41;</span></pre></div></div>

<p>The request method can be directly determined using <code>(Request:method)</code>.  The path and domain are stored in <code>Request:path</code> and <code>Request:domain</code>, respectively.  I included one other feature of interest for those who use mod_rewrite to create pretty urls.<br />
<code>(Request:segment)</code> allows access to the individual url path segments.  If called with an integer argument, it will attempt to return the segment at that index.  Calling a higher index than exists results in an out of bounds error.  If <code>(Request:segment)</code> is called sequentially, it will return the next segment in the list until there are no more segments left, after which it will return <code>nil</code>.  Sample usage:</p>

<div class="wp_syntax"><div class="code"><pre class="lisp" style="font-family:monospace;"><span style="color: #66cc66;">&#40;</span>while <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">set</span> 's <span style="color: #66cc66;">&#40;</span>Request<span style="color: #66cc66;">:</span><span style="color: #555;">segment</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
    <span style="color: #66cc66;">&#40;</span>do-something-with s<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span></pre></div></div>

<p>Additionally, the entire set of segments can be accessed as a list using <code>(Request:segments)</code>.</p>
<p>The <code>Response</code> module contains functions to control the output of HTTP headers.  Generic headers may be set using <code>(Response:header "foo" "bar")</code> and the current set of headers may be queried with <code>(Response:header? "foo")</code>.  Content-type is handled automatically, although it may be overridden, e.g. <code>(Response:header "Content-type" "text/plain")</code>.  The default content type is <code>text/html; charset=utf-8</code>.</p>
<p>Adding display content to the response in simple.<br />
<code>(Response:write "foo")</code> will modify the content in place.  This may be overridden when outputting the content using the default functor, e.g. <code>(Response "foo")</code>.  The result of this is a string; it must be printed to the browser.  Other types of output may be achieved with various functions:</p>

<div class="wp_syntax"><div class="code"><pre class="lisp" style="font-family:monospace;"><span style="color: #66cc66;">&#40;</span>print <span style="color: #66cc66;">&#40;</span>Response<span style="color: #66cc66;">:</span><span style="color: #555;">redirect</span> <span style="color: #ff0000;">&quot;/some/other/path/&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#40;</span>print <span style="color: #66cc66;">&#40;</span>Response<span style="color: #66cc66;">:</span><span style="color: #b1b100;">error</span> <span style="color: #ff0000;">&quot;
&nbsp;
Some error has occurred
&nbsp;
&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#40;</span>print <span style="color: #66cc66;">&#40;</span>Response<span style="color: #66cc66;">:</span><span style="color: #555;">not-found</span> <span style="color: #ff0000;">&quot;
&nbsp;
Page not found
&nbsp;
&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span></pre></div></div>

<p>There are usage examples at the top of the module.  Custom handlers need only override the internal function, <code>(Response:_response)</code>, which simply outputs the entire page, including headers.</p>
<p>Cookies are dealt with using generic syntax and are automatically added to response output.</p>

<div class="wp_syntax"><div class="code"><pre class="lisp" style="font-family:monospace;"><span style="color: #66cc66;">&#40;</span>Response<span style="color: #66cc66;">:</span><span style="color: #555;">set-cookie</span> <span style="color: #ff0000;">&quot;foo&quot;</span> <span style="color: #ff0000;">&quot;bar&quot;</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#40;</span>Response<span style="color: #66cc66;">:</span><span style="color: #555;">delete-cookie</span> <span style="color: #ff0000;">&quot;foo&quot;</span><span style="color: #66cc66;">&#41;</span></pre></div></div>

<p>Finally, one thing that users of the CGI module may miss is the <code>put-page</code> routine.  At the moment, there is no equivalent to this in the <code>Response</code> module.  I am currently working on a Template module that will provide similar functionality.  Until then, there is no reason that <code>put-page</code> could not be copied and pasted into <code>Response</code> (or elsewhere) as required.</p>
<p>One note of warning:<br />
<code>Request</code> and the newLISP CGI module will not work together.  Once the POST data has been read from stdin, it is consumed.  Whichever module is called first will have the POST data, which will be unavailable to the other module.</p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a><strong><em>Submit article</em></strong></a>
<br />
<div class="d">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http%3A%2F%2Fwww.artfulcode.net%2Farticles%2Frequest-and-response-modules-newlisp%2F&amp;title=Request+and+Response+modules+for+newLISP" rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://www.artfulcode.net/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.artfulcode.net%2Farticles%2Frequest-and-response-modules-newlisp%2F&amp;title=Request+and+Response+modules+for+newLISP" rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://www.artfulcode.net/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.dzone.com/links/add.html?description=Request+and+Response+modules+for+newLISP&amp;url=http%3A%2F%2Fwww.artfulcode.net%2Farticles%2Frequest-and-response-modules-newlisp%2F&amp;title=Request+and+Response+modules+for+newLISP" rel="nofollow" title="Add to&nbsp;DZone"><img class="social_img" src="http://www.artfulcode.net/wp-content/plugins/social-bookmarks/images/dzone.png" title="Add to&nbsp;DZone" alt="Add to&nbsp;DZone" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http%3A%2F%2Fwww.artfulcode.net%2Farticles%2Frequest-and-response-modules-newlisp%2F" rel="nofollow" title="Add to&nbsp;Facebook"><img class="social_img" src="http://www.artfulcode.net/wp-content/plugins/social-bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http%3A%2F%2Fwww.artfulcode.net%2Farticles%2Frequest-and-response-modules-newlisp%2F&amp;title=Request+and+Response+modules+for+newLISP" rel="nofollow" title="Add to&nbsp;reddit"><img class="social_img" src="http://www.artfulcode.net/wp-content/plugins/social-bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.artfulcode.net%2Farticles%2Frequest-and-response-modules-newlisp%2F&amp;title=Request+and+Response+modules+for+newLISP" rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://www.artfulcode.net/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http%3A%2F%2Fwww.artfulcode.net%2Farticles%2Frequest-and-response-modules-newlisp%2F" rel="nofollow" title="Add to&nbsp;Technorati"><img class="social_img" src="http://www.artfulcode.net/wp-content/plugins/social-bookmarks/images/technorati.png" title="Add to&nbsp;Technorati" alt="Add to&nbsp;Technorati" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://twitter.com/home/?status=Check+out+Request+and+Response+modules+for+newLISP+@+http%3A%2F%2Fwww.artfulcode.net%2Farticles%2Frequest-and-response-modules-newlisp%2F" rel="nofollow" title="Add to&nbsp;Twitter"><img class="social_img" src="http://www.artfulcode.net/wp-content/plugins/social-bookmarks/images/twitter.png" title="Add to&nbsp;Twitter" alt="Add to&nbsp;Twitter" /></a>
<br />
</div>
</div>
<!-- Social Bookmarks END -->
]]></content:encoded>
			<wfw:commentRss>http://www.artfulcode.net/articles/request-and-response-modules-newlisp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

