<?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>nklein software &#187; lisp</title>
	<atom:link href="http://nklein.com/lisp/feed/" rel="self" type="application/rss+xml" />
	<link>http://nklein.com</link>
	<description>software development and consulting</description>
	<lastBuildDate>Thu, 22 Dec 2011 04:42:24 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Dusting off my Growl Library</title>
		<link>http://nklein.com/2011/12/dusting-off-my-growl-library/</link>
		<comments>http://nklein.com/2011/12/dusting-off-my-growl-library/#comments</comments>
		<pubDate>Thu, 22 Dec 2011 04:42:24 +0000</pubDate>
		<dc:creator>pat</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[cl-growl]]></category>
		<category><![CDATA[iolib]]></category>
		<category><![CDATA[ironclad]]></category>
		<category><![CDATA[lisp]]></category>
		<category><![CDATA[usocket]]></category>

		<guid isPermaLink="false">http://nklein.com/?p=1782</guid>
		<description><![CDATA[I&#8217;ve spent the last few hours dusting off my Common Lisp Growl client library. The last time I worked on it was before the Mac Growl Application supported GNTP (Growl Notification Transport Protocol). Today, working on it, I&#8217;m not quite sure what&#8217;s up, but I am not succeeding in communicating with the server using encryption. [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve spent the last few hours dusting off my <a href="http://nklein.com/software/cl-growl/">Common Lisp Growl client library</a>.  The last time I worked on it was before the Mac Growl Application supported GNTP (Growl Notification Transport Protocol).</p>
<p>Today, working on it, I&#8217;m not quite sure what&#8217;s up, but I am not succeeding in communicating with the server using encryption.  I&#8217;ll have to look more closely.  Last time that I worked on it, I extended <a href="http://method-combination.net/lisp/ironclad/">Ironclad</a>, but I never got those changes pushed fully into Ironclad&#8217;s main line.  But, I think I&#8217;m using the same version of Ironclad that I was using when I tested against the Windows Growl Application.  *shrug*</p>
<p>I&#8217;ve also run into a snag with the Callbacks.  Essentially, your Lisp program could get a callback when the user has clicked on your Growl notification.  This actually works except for the fact that I am calling <code class="codecolorer lisp default"><span class="lisp">READ-SEQUENCE</span></code> into a buffer that is longer than the message.  The server, I believe, is supposed to close the socket after the callback.  But, it does not.  So, I am stuck waiting for more bytes that will never come.</p>
<p>Now, I either have to do one of the following:</p>
<ul>
<li>refactor it to use <code class="codecolorer lisp default"><span class="lisp">READ-LINE</span></code> instead</li>
<li>switch from using <a href="http://common-lisp.net/project/usocket/">USocket</a> to using <a href="http://common-lisp.net/project/iolib/">IOLib</a> (and hope that <code class="codecolorer lisp default"><span class="lisp"><span style="color: #66cc66;">:</span><span style="color: #555;">dont-wait</span></span></code> works as expected)</li>
<li>extend USocket to support <code class="codecolorer lisp default"><span class="lisp">SOCKET-RECEIVE</span></code> even on TCP sockets</li>
</ul>
<p>Anyone have a preference?</p>
]]></content:encoded>
			<wfw:commentRss>http://nklein.com/2011/12/dusting-off-my-growl-library/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Keeping Server and Client Separate</title>
		<link>http://nklein.com/keeping-server-and-client-separate</link>
		<comments>http://nklein.com/keeping-server-and-client-separate#comments</comments>
		<pubDate>Thu, 08 Sep 2011 19:51:33 +0000</pubDate>
		<dc:creator>pat</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[c++]]></category>
		<category><![CDATA[client-server]]></category>
		<category><![CDATA[lisp]]></category>
		<category><![CDATA[literate programming]]></category>
		<category><![CDATA[userial]]></category>

		<guid isPermaLink="false">http://nklein.com/?p=1758</guid>
		<description><![CDATA[The problem Whenever I write client-server applications, I run into the same problem trying to separate the code. To send a message from the server to the client, the server has to serialize that message and the client has to unserialize that message. The server doesn&#8217;t need to unserialize that message. The client doesn&#8217;t need [...]]]></description>
			<content:encoded><![CDATA[<h3>The problem</h3>
<p>Whenever I write client-server applications, I run into the same problem trying to separate the code.  To send a message from the server to the client, the server has to serialize that message and the client has to unserialize that message.  The server doesn&#8217;t need to unserialize that message.  The client doesn&#8217;t need to serialize that message.</p>
<p>It seems wrong to include both the serialization code and the unserialization code in both client and server when each side will only be using 1/2 of that code.  On the other hand, it seems bad to keep the serialization and unserialization code in separate places.  You don&#8217;t want one side serializing A+B+C and the other side trying to unserialize A+C+D+B.</p>
<h3>One approach: data classes</h3>
<p>Some projects deal with this situation by making every message have its own data class.  You take all of the information that you want to be in the message and plop it into a data class.  You then serialize the data class and send the resulting bytes.  The other side unserializes the bytes into a data class and plucks the data out of the data class.</p>
<p>The advantage here is that you can have some metaprogram read the data class definition and generate a serializer or unserializer as needed.  You&#8217;re only out-of-sync if one side hasn&#8217;t regenerated since the data class definition changed.</p>
<p>The disadvantage here is that I loathe data classes.  If my top-level interface is going to be <code class="codecolorer lisp default"><span class="lisp"><span style="color: #66cc66;">&#40;</span>send-login username password<span style="color: #66cc66;">&#41;</span></span></code>, then why can&#8217;t I just serialize straight from there without having to create a dippy data structure to hold my opcode and two strings?</p>
<h3>Another approach: suck it up</h3>
<p>Who cares if the client contains both the serialization and unserialization code?  Heck, if you&#8217;re really all that concerned, then <code class="codecolorer lisp default"><span class="lisp">fmakunbound</span></code> half the universe before you <code class="codecolorer lisp default"><span class="lisp">save-lisp-and-die</span></code>.</p>
<p>Of course, unless you&#8217;re using data classes, you&#8217;re either going to have code in your client that references a bunch of functions and variables that only exist in your server or your client and server will be identical except for:</p>
<div class="codecolorer-container lisp blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><pre class="lisp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">defun</span> main <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
  #+server <span style="color: #66cc66;">&#40;</span>server-main<span style="color: #66cc66;">&#41;</span>
  #-server <span style="color: #66cc66;">&#40;</span>client-main<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span></pre></div>
<p>Now, of course, your server is going to accidentally depend on OpenGL and OpenAL and SDL and a whole bunch of other -L&#8217;s it never actually calls.  Meanwhile, your client is going to accidentally depend on Postmodern and Portable-Threads and a whole bunch of other Po-&#8217;s it never actually calls.</p>
<h3>Another approach: tangle and weave, baby</h3>
<p>Another way that I&#8217;ve got around this is to use literate programming tools to let me write the serialiization and unserialization right next to each other in my document.  Then, anyone going to change the serialize code would be immediately confronted with the unserialize code that goes with it.</p>
<p>The advantage here is that you can tangle the client code through an entirely separate path than the server code keeping only what you need in each.</p>
<p>The disadvantage here is that now both your client code and your server code have to be in the same document or both include the same sizable chunk of document.  And, while there aren&#8217;t precisely name-capturing problems, trying to include the &#8220;serialize-and-send&#8221; chunk in your function in the client code still requires that you use the same variable names that were in that chunk.</p>
<h3>How can Lisp make this better?</h3>
<p>In Lisp, we can get the benefits of a data-definition language and data classes without needing the data classes.  Here&#8217;s a snippet of the data definition for a simple client-server protocol.</p>
<div class="codecolorer-container lisp blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><pre class="lisp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #808080; font-style: italic;">;;;; protocol.lisp</span>
<span style="color: #66cc66;">&#40;</span>userial<span style="color: #66cc66;">:</span><span style="color: #555;">make-enum-serializer</span> <span style="color: #66cc66;">:</span><span style="color: #555;">opcode</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">:</span><span style="color: #555;">ping</span> <span style="color: #66cc66;">:</span><span style="color: #555;">ping-ack</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#40;</span>defmessage <span style="color: #66cc66;">:</span><span style="color: #555;">ping</span>     <span style="color: #66cc66;">:</span><span style="color: #555;">uint32</span> ping-payload<span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#40;</span>defmessage <span style="color: #66cc66;">:</span><span style="color: #555;">ping-ack</span> <span style="color: #66cc66;">:</span><span style="color: #555;">uint32</span> ping-payload<span style="color: #66cc66;">&#41;</span></pre></div>
<p>I&#8217;ve declared there are two different types of messages, each with their own opcode.  Now, I have macros for <code class="codecolorer lisp default"><span class="lisp">define-sender</span></code> and <code class="codecolorer lisp default"><span class="lisp">define-handler</span></code> that allow me to create functions which have no control over the actual serialization and unserialization.  My functions can only manipulate the named message parameters (the value of <code class="codecolorer lisp default"><span class="lisp">ping-payload</span></code> in this case) before serialization or after unserialization but cannot change the serialization or unserialization itself.</p>
<p>With this protocol, the client side has to handle ping messages by sending ping-ack messages.  The <code class="codecolorer lisp default"><span class="lisp">define-sender</span></code> macro takes the opcode of the message (used to identify the message fields), the name of the function to create, the argument list for the function (which may include declarations for some or all of the fields in the message), the form to use for the address to send the resulting message to, and any body needed to set fields in the packet based on the function arguments before the serialization.  The <code class="codecolorer lisp default"><span class="lisp">define-handler</span></code> macro takes the opcode of the message (again, used to identify the message fields), the name of the function to create, the argument list for the function, the form to use for the buffer to unserialize, and any body needed to act on the unserialized message fields.</p>
<div class="codecolorer-container lisp blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><pre class="lisp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #808080; font-style: italic;">;;;; client.lisp</span>
<span style="color: #66cc66;">&#40;</span>define-sender  <span style="color: #66cc66;">:</span><span style="color: #555;">ping-ack</span> send-ping-ack <span style="color: #66cc66;">&#40;</span>ping-payload<span style="color: #66cc66;">&#41;</span> *server-address*<span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#40;</span>define-handler <span style="color: #66cc66;">:</span><span style="color: #555;">ping</span>     handle-ping   <span style="color: #66cc66;">&#40;</span>buffer<span style="color: #66cc66;">&#41;</span> buffer
  <span style="color: #66cc66;">&#40;</span>send-ping-ack ping-payload<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span></pre></div>
<p>The server side has a bit more work to do because it&#8217;s going to generate the sequence numbers and track the round-trip ping times.</p>
<div class="codecolorer-container lisp blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><pre class="lisp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #808080; font-style: italic;">;;;; server.lisp</span>
&nbsp;
<span style="color: #66cc66;">&#40;</span>defvar *last-ping-payload* <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#40;</span>defvar *last-ping-time*    <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
<span style="color: #66cc66;">&#40;</span>define-sender <span style="color: #66cc66;">:</span><span style="color: #555;">ping</span> send-ping <span style="color: #66cc66;">&#40;</span>who<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#40;</span>get-address-of who<span style="color: #66cc66;">&#41;</span>
  <span style="color: #66cc66;">&#40;</span>incf *last-ping-payload*<span style="color: #66cc66;">&#41;</span>
  <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">setf</span> *last-ping-time*    <span style="color: #66cc66;">&#40;</span>get-internal-real-time<span style="color: #66cc66;">&#41;</span>
        ping-payload        *last-ping-payload*<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
<span style="color: #66cc66;">&#40;</span>define-handler <span style="color: #66cc66;">:</span><span style="color: #555;">ping-ack</span> handle-ping-ack <span style="color: #66cc66;">&#40;</span>who buffer<span style="color: #66cc66;">&#41;</span> buffer
  <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">when</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">=</span> ping-payload *last-ping-payload*<span style="color: #66cc66;">&#41;</span>
    <span style="color: #66cc66;">&#40;</span>update-ping-time who <span style="color: #66cc66;">&#40;</span>- <span style="color: #66cc66;">&#40;</span>get-internal-real-time<span style="color: #66cc66;">&#41;</span> *last-ping-time*<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>
<h3>Problems with the above</h3>
<p>It feels strange to leave compile-time artifacts like the names and types of the message fields in the code after I&#8217;ve generated the functions that I&#8217;m actually going to use.  But, I guess that&#8217;s just part of Lisp development.  You can&#8217;t (easily) unload a package.  I can <code class="codecolorer lisp default"><span class="lisp">makunbound</span></code> a bunch of stuff after I&#8217;m loaded if I don&#8217;t want it to be convenient to modify senders or handlers at run-time.</p>
<p>There is intentional name-capture going on.  The names of the message fields become names in the handlers.  The biggest problem with this is that the <code class="codecolorer lisp default"><span class="lisp">defmessage</span></code> calls really have to be in the same namespace as the <code class="codecolorer lisp default"><span class="lisp">define-sender</span></code> and <code class="codecolorer lisp default"><span class="lisp">define-handler</span></code> calls.</p>
<p>I still have some work to do on my macros to support <code class="codecolorer lisp default"><span class="lisp"><span style="color: #66cc66;">&amp;</span>key</span></code> and <code class="codecolorer lisp default"><span class="lisp"><span style="color: #66cc66;">&amp;</span>optional</span></code> and <code class="codecolorer lisp default"><span class="lisp"><span style="color: #66cc66;">&amp;</span>aux</span></code> and <code class="codecolorer lisp default"><span class="lisp"><span style="color: #66cc66;">&amp;</span>rest</span></code> arguments properly.  I will post those macros once I&#8217;ve worked out those kinks.</p>
<p>Anyone care to share how they&#8217;ve tackled client-server separation before?</p>
]]></content:encoded>
			<wfw:commentRss>http://nklein.com/keeping-server-and-client-separate/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Blackthorn 3D &#8212; Lisp game engine using USerial</title>
		<link>http://nklein.com/2011/06/blackthorn-3d-lisp-game-engine-using-userial/</link>
		<comments>http://nklein.com/2011/06/blackthorn-3d-lisp-game-engine-using-userial/#comments</comments>
		<pubDate>Mon, 20 Jun 2011 23:35:00 +0000</pubDate>
		<dc:creator>pat</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[lisp]]></category>
		<category><![CDATA[userial]]></category>

		<guid isPermaLink="false">http://nklein.com/?p=1751</guid>
		<description><![CDATA[Elliott Slaughter announced Blackthorn 3D, yesterday. Blackthorn 3D is a game engine crafted in Lisp using LispbuilderSDL and cl-opengl for graphics and usocket and userial for network play.]]></description>
			<content:encoded><![CDATA[<p>Elliott Slaughter announced <a href="http://elliottslaughter.com/2011/06/blackthorn-3d">Blackthorn 3D</a>, yesterday.  Blackthorn 3D is a game engine crafted in Lisp using <a href="http://code.google.com/p/lispbuilder/wiki/LispbuilderSDL">LispbuilderSDL</a> and <a href="http://common-lisp.net/project/cl-opengl/">cl-opengl</a> for graphics and <a href="http://common-lisp.net/project/usocket/">usocket</a> and <a href="http://nklein.com/software/unet/userial/">userial</a> for network play.</p>
]]></content:encoded>
			<wfw:commentRss>http://nklein.com/2011/06/blackthorn-3d-lisp-game-engine-using-userial/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>C- in MacOSX&#8217;s Terminal.app</title>
		<link>http://nklein.com/2011/06/c-in-macosxs-terminal-app/</link>
		<comments>http://nklein.com/2011/06/c-in-macosxs-terminal-app/#comments</comments>
		<pubDate>Tue, 14 Jun 2011 06:25:24 +0000</pubDate>
		<dc:creator>pat</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[emacs]]></category>
		<category><![CDATA[lisp]]></category>

		<guid isPermaLink="false">http://nklein.com/?p=1747</guid>
		<description><![CDATA[After tonight&#8217;s TC Lispers Meeting, I had a renewed interest in figuring out why C-&#60;right arrow&#62; didn&#8217;t work for me in Org-Mode or Paredit. After a whole bunch of running in circles, I have discovered a combination that works (with these clues). I have my TERM variable set to xterm-color. I configured the Terminal.app using [...]]]></description>
			<content:encoded><![CDATA[<p>After tonight&#8217;s <a href="http://tclispers.org/events/june-meeting-emacs-theme">TC Lispers Meeting</a>, I had a renewed interest in figuring out why C-&lt;right arrow&gt; didn&#8217;t work for me in Org-Mode or Paredit.</p>
<p>After a whole bunch of running in circles, I have discovered a combination that works (with <a href="http://marc-abramowitz.com/archives/2006/10/05/ctrl-left-and-ctrl-right-in-bash-and-emacs/">these clues</a>).  I have my <code class="codecolorer text default"><span class="text">TERM</span></code> variable set to <code class="codecolorer text default"><span class="text">xterm-color</span></code>.  I configured the Terminal.app using its Keyboard settings to have it send the string &#8220;\033[1;5C&#8221; for C-&lt;right arrow&gt; and &#8220;\033[1;5D&#8221; for C-&lt;left arrow&gt;.  (The &#8220;\033&#8243; is the escape key.)</p>
<p>This works for me even through <code class="codecolorer text default"><span class="text">screen</span></code>.</p>
<p>Bonus.</p>
]]></content:encoded>
			<wfw:commentRss>http://nklein.com/2011/06/c-in-macosxs-terminal-app/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>USerial &#8212; v0.8.2011.06.02</title>
		<link>http://nklein.com/2011/06/userial-v0-8-2011-06-02-2/</link>
		<comments>http://nklein.com/2011/06/userial-v0-8-2011-06-02-2/#comments</comments>
		<pubDate>Fri, 03 Jun 2011 00:31:40 +0000</pubDate>
		<dc:creator>pat</dc:creator>
				<category><![CDATA[New Versions]]></category>
		<category><![CDATA[Releases]]></category>
		<category><![CDATA[lisp]]></category>
		<category><![CDATA[userial]]></category>

		<guid isPermaLink="false">http://nklein.com/?p=1745</guid>
		<description><![CDATA[I am releasing a new version of the USerial library. New in this version: Fix (make-int-serializer) to be big-endian 2&#8242;s complement Add :symbol and :keyword serializers Add (make-vector-serializer) Add (make-key-slot-serializer) and (make-key-accessor-serializer) Add (define-serializing-funcall) Obtaining The USerial home page: http://nklein.com/software/unet/userial/ The tarball: userial_0.8.2011.06.02.tar.gz The signature: userial_0.8.2011.06.02.tar.gz.asc The main git repository: http://git.nklein.com/lisp/libs/userial.git/ Browsable git mirror: https://github.com/nklein/userial [...]]]></description>
			<content:encoded><![CDATA[<p>I am releasing a new version of the USerial library.  New in this version:</p>
<ul>
<li>Fix (make-int-serializer) to be big-endian 2&#8242;s complement</li>
<li>Add :symbol and :keyword serializers</li>
<li>Add (make-vector-serializer)</li>
<li>Add (make-key-slot-serializer) and (make-key-accessor-serializer)</li>
<li>Add (define-serializing-funcall)</li>
</ul>
<h3>Obtaining</h3>
<ul>
<li>The USerial home page: <a href="http://nklein.com/software/unet/userial/">http://nklein.com/software/unet/userial/</a></li>
<li>The tarball:  <a href="http://nklein.com/wp-content/uploads/2011/06/userial_0.8.2011.06.02.tar.gz">userial_0.8.2011.06.02.tar.gz</a></li>
<li>The signature: <a href="http://nklein.com/wp-content/uploads/2011/06/userial_0.8.2011.06.02.tar.gz.asc">userial_0.8.2011.06.02.tar.gz.asc</a></li>
<li>The main git repository: <a href="http://git.nklein.com/lisp/libs/userial.git">http://git.nklein.com/lisp/libs/userial.git/</a></li>
<li>Browsable git mirror: <a href="https://github.com/nklein/userial">https://github.com/nklein/userial</a></li>
<li>Issue reporting: <a href="https://github.com/nklein/userial/issues">https://github.com/nklein/userial/issues</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://nklein.com/2011/06/userial-v0-8-2011-06-02-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Quicklisp Win:  Weblocks</title>
		<link>http://nklein.com/2011/06/quicklisp-win-weblocks/</link>
		<comments>http://nklein.com/2011/06/quicklisp-win-weblocks/#comments</comments>
		<pubDate>Thu, 02 Jun 2011 21:31:02 +0000</pubDate>
		<dc:creator>pat</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[lisp]]></category>
		<category><![CDATA[quicklisp]]></category>

		<guid isPermaLink="false">http://nklein.com/?p=1732</guid>
		<description><![CDATA[I was recently reminded of a presentation that I gave last year about Weblocks. Here&#8217;s one slide from that presentation: Today, I started from scratch in an empty account on an eight-year-old Linux box. I installed Quicklisp and used it to install Weblocks. I had a Weblocks server up and running in under three minutes.]]></description>
			<content:encoded><![CDATA[<p>I was recently reminded of <a href="http://nklein.com/2010/04/tc-lispers-april-presentations-online/">a presentation</a> that I gave last year about <a href="http://common-lisp.net/project/cl-weblocks/">Weblocks</a>.</p>
<p>Here&#8217;s one slide from that presentation:<br />
<a href="http://nklein.com/wp-content/uploads/2011/06/weblocks-deps.png"><img src="http://nklein.com/wp-content/uploads/2011/06/weblocks-deps.png" alt="" title="weblocks-deps" width="650" height="484" class="aligncenter size-full wp-image-1733" /></a></p>
<p>Today, I started from scratch in an empty account on an eight-year-old Linux box.  I installed <a href="http://quicklisp.org/">Quicklisp</a> and used it to install Weblocks.  I had a Weblocks server up and running in under three minutes.</p>
]]></content:encoded>
			<wfw:commentRss>http://nklein.com/2011/06/quicklisp-win-weblocks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>USerial &#8212; v0.7.2011.05.24</title>
		<link>http://nklein.com/2011/05/userial-v0-7-2011-05-24-3/</link>
		<comments>http://nklein.com/2011/05/userial-v0-7-2011-05-24-3/#comments</comments>
		<pubDate>Wed, 25 May 2011 04:28:43 +0000</pubDate>
		<dc:creator>pat</dc:creator>
				<category><![CDATA[New Versions]]></category>
		<category><![CDATA[Releases]]></category>
		<category><![CDATA[lisp]]></category>
		<category><![CDATA[userial]]></category>

		<guid isPermaLink="false">http://nklein.com/?p=1728</guid>
		<description><![CDATA[I am releasing a new version of my USerial library. This version cleans up many messes from earlier releases. Unfortunately, in that process, it breaks compatibility with earlier releases. Obtaining Getting the USerial library: The home page: http://nklein.com/software/unet/userial/ The tar-ball: userial_0.7.2011.05.24.tar.gz The GPG signature for the tar-ball: userial_0.7.2011.05.24.tar.gz.asc The main git repository: http://git.nklein.com/lisp/libs/userial.git A browsable [...]]]></description>
			<content:encoded><![CDATA[<p>I am releasing a new version of my <a href="http://nklein.com/software/unet/userial/userial">USerial</a> library. This version cleans up many messes from earlier releases. Unfortunately, in that process, it breaks compatibility with earlier releases.</p>
<h4>Obtaining</h4>
<p>Getting the USerial library:</p>
<ul>
<li>The home page: <a href="http://nklein.com/software/unet/userial/">http://nklein.com/software/unet/userial/</a></li>
<li>The tar-ball: <a href="http://nklein.com/wp-content/uploads/2011/05/userial_0.7.2011.05.24.tar.gz">userial_0.7.2011.05.24.tar.gz</a></li>
<li>The GPG signature for the tar-ball: <a href="http://nklein.com/wp-content/uploads/2011/05/userial_0.7.2011.05.24.tar.gz.asc">userial_0.7.2011.05.24.tar.gz.asc</a></li>
<li>The main git repository: <a href="http://git.nklein.com/lisp/libs/userial.git/">http://git.nklein.com/lisp/libs/userial.git</a></li>
<li>A browsable mirror of the git repository: <a href="http://github.com/nklein/userial/">http://github.com/nklein/userial</a></li>
</ul>
<h4>Differences</h4>
<p>The differences between this version and earlier versions of this library include:</p>
<ul>
<li>Use of <a href="http://common-lisp.net/project/closer/contextl.html">ContextL</a> layered functions instead of CLOS methods</li>
<li>Elimination of <code class="codecolorer lisp default"><span class="lisp"><span style="color: #66cc66;">:</span><span style="color: #555;">buffer</span></span></code> parameter in favor of using the <code class="codecolorer lisp default"><span class="lisp">*buffer*</span></code> special variable</li>
<li>Cleaning up macros which no longer required the <code class="codecolorer lisp default"><span class="lisp"><span style="color: #66cc66;">:</span><span style="color: #555;">buffer</span></span></code> parameter</li>
<li>Serializers for arbitrarily large integers and unsigned integers</li>
<li>Serializer for raw sequence of bytes</li>
<li>New <code class="codecolorer lisp default"><span class="lisp">make-list-serializer</span></code> macro</li>
</ul>
<p>By using ContextL layered functions, one has the ability to define a serializer and/or unserializer in a particular ContextL layer.  This can be used to create new versions of the serializer without losing the ability to use the older version when required.</p>
<p>In the process, I have created macros to assist in creating completely custom serializers.  This both streamlines their definition and should allow any future modifications to the USerial library to fly under the radar.  Code that before looked like this:</p>
<div class="codecolorer-container lisp blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><pre class="lisp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #66cc66;">&#40;</span>defmethod serialize <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>key <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">eql</span> <span style="color: #66cc66;">:</span><span style="color: #555;">foo</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">value</span> foo-struct<span style="color: #66cc66;">&#41;</span>
                      <span style="color: #66cc66;">&amp;</span>key <span style="color: #66cc66;">&#40;</span>buffer userial<span style="color: #66cc66;">:</span>*buffer*<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&amp;</span>amp<span style="color: #808080; font-style: italic;">;allow-other-keys)</span>
  <span style="color: #66cc66;">...</span> some code <span style="color: #66cc66;">...</span>
  buffer<span style="color: #66cc66;">&#41;</span>
&nbsp;
<span style="color: #66cc66;">&#40;</span>defmethod unserialize <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>key <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">eql</span> <span style="color: #66cc66;">:</span><span style="color: #555;">foo</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
                        <span style="color: #66cc66;">&amp;</span>key <span style="color: #66cc66;">&#40;</span>buffer userial<span style="color: #66cc66;">:</span>*buffer*<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&amp;</span>amp<span style="color: #808080; font-style: italic;">;allow-other-keys)</span>
  <span style="color: #66cc66;">&#40;</span>values <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">progn</span> <span style="color: #66cc66;">...</span> some code <span style="color: #66cc66;">...</span><span style="color: #66cc66;">&#41;</span>
          buffer<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span></pre></div>
<p>Should now look like this:</p>
<div class="codecolorer-container lisp blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><pre class="lisp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #66cc66;">&#40;</span>define-serializer <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">:</span><span style="color: #555;">foo</span> <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">value</span> foo-struct<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
  <span style="color: #66cc66;">...</span> some code <span style="color: #66cc66;">...</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
<span style="color: #66cc66;">&#40;</span>define-unserializer <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">:</span><span style="color: #555;">foo</span><span style="color: #66cc66;">&#41;</span>
  <span style="color: #66cc66;">...</span> some code <span style="color: #66cc66;">...</span><span style="color: #66cc66;">&#41;</span></pre></div>
<p>And, when you find you need to add a new version of your <code class="codecolorer lisp default"><span class="lisp"><span style="color: #66cc66;">:</span><span style="color: #555;">foo</span></span></code> serializer but you don&#8217;t want to lose the old one, you can add:</p>
<div class="codecolorer-container lisp blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><pre class="lisp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #66cc66;">&#40;</span>contextl<span style="color: #66cc66;">:</span><span style="color: #555;">deflayer</span> new-version<span style="color: #66cc66;">&#41;</span>
&nbsp;
<span style="color: #66cc66;">&#40;</span>define-serializer <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">:</span><span style="color: #555;">foo</span> <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">value</span> foo-struct<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">:</span><span style="color: #555;">layer</span> new-version<span style="color: #66cc66;">&#41;</span>
  <span style="color: #66cc66;">...</span> some new code <span style="color: #66cc66;">...</span><span style="color: #66cc66;">&#41;</span></pre></div>
<p>Without the <code class="codecolorer lisp default"><span class="lisp"><span style="color: #66cc66;">:</span><span style="color: #555;">buffer</span></span></code> parameter everywhere, code that used to look like this:</p>
<div class="codecolorer-container lisp blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><pre class="lisp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #66cc66;">&#40;</span>serialize* <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">:</span><span style="color: #555;">string</span> aa <span style="color: #66cc66;">:</span><span style="color: #555;">uint8</span> bb<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">:</span><span style="color: #555;">buffer</span> buf<span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#40;</span>buffer-rewind <span style="color: #66cc66;">:</span><span style="color: #555;">buffer</span> buf<span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#40;</span>unserialize-slots* <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">:</span><span style="color: #555;">string</span> <span style="color: #b1b100;">name</span> <span style="color: #66cc66;">:</span><span style="color: #555;">uint8</span> age<span style="color: #66cc66;">&#41;</span> object <span style="color: #66cc66;">:</span><span style="color: #555;">buffer</span> buf<span style="color: #66cc66;">&#41;</span></pre></div>
<p>Should now look like this:</p>
<div class="codecolorer-container lisp blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><pre class="lisp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #66cc66;">&#40;</span>with-buffer buf
  <span style="color: #66cc66;">&#40;</span>serialize* <span style="color: #66cc66;">:</span><span style="color: #555;">string</span> aa <span style="color: #66cc66;">:</span><span style="color: #555;">uint8</span> bb<span style="color: #66cc66;">&#41;</span>
  <span style="color: #66cc66;">&#40;</span>buffer-rewind<span style="color: #66cc66;">&#41;</span>
  <span style="color: #66cc66;">&#40;</span>unserialize-slots* object <span style="color: #66cc66;">:</span><span style="color: #555;">string</span> <span style="color: #b1b100;">name</span> <span style="color: #66cc66;">:</span><span style="color: #555;">uint</span> age<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span></pre></div>
<p>There are now <code class="codecolorer lisp default"><span class="lisp"><span style="color: #66cc66;">:</span><span style="color: #555;">int</span></span></code> and <code class="codecolorer lisp default"><span class="lisp"><span style="color: #66cc66;">:</span><span style="color: #555;">uint</span></span></code> serializers that encode arbitrarily large integers and unsigned integers, respectively.  There is also a serializer that copies a sequence of bytes as is without any prefix or suffix. To unserialize, you either have to provide a buffer of the appropriate length with the <code class="codecolorer lisp default"><span class="lisp"><span style="color: #66cc66;">:</span><span style="color: #555;">output</span></span></code> parameter or provide appropriate <code class="codecolorer lisp default"><span class="lisp"><span style="color: #66cc66;">:</span><span style="color: #555;">start</span></span></code> and <code class="codecolorer lisp default"><span class="lisp"><span style="color: #66cc66;">:</span><span style="color: #555;">end</span></span></code> keywords.</p>
<div class="codecolorer-container lisp blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><pre class="lisp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #66cc66;">&#40;</span>serialize <span style="color: #66cc66;">:</span><span style="color: #555;">raw-bytes</span> uchar-<span style="color: #b1b100;">array</span> <span style="color: #66cc66;">&amp;</span>key <span style="color: #66cc66;">&#40;</span>start <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>
                                       <span style="color: #66cc66;">&#40;</span>end <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">length</span> uchar-<span style="color: #b1b100;">array</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>unserialize <span style="color: #66cc66;">:</span><span style="color: #555;">raw-bytes</span> <span style="color: #66cc66;">&amp;</span>key output
                             <span style="color: #66cc66;">&#40;</span>start <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>
                             <span style="color: #66cc66;">&#40;</span>end <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">length</span> output<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span></pre></div>
<p>And, if you have a serialize/unserialize pair for type <code class="codecolorer lisp default"><span class="lisp"><span style="color: #66cc66;">:</span><span style="color: #555;">foo</span></span></code> you can use the <code class="codecolorer lisp default"><span class="lisp">make-list-serializer</span></code> macro to create a serialize/unserialize pair for a list of items that can be serialized with the <code class="codecolorer lisp default"><span class="lisp"><span style="color: #66cc66;">:</span><span style="color: #555;">foo</span></span></code> serializer.</p>
<div class="codecolorer-container lisp blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><pre class="lisp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #66cc66;">&#40;</span>make-list-serializer <span style="color: #66cc66;">:</span><span style="color: #555;">list-of-uint8</span> <span style="color: #66cc66;">:</span><span style="color: #555;">uint8</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#40;</span>serialize <span style="color: #66cc66;">:</span><span style="color: #555;">list-of-int8</span> '<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">1</span> <span style="color: #cc66cc;">1</span> <span style="color: #cc66cc;">2</span> <span style="color: #cc66cc;">3</span> <span style="color: #cc66cc;">5</span> <span style="color: #cc66cc;">8</span> <span style="color: #cc66cc;">13</span> <span style="color: #cc66cc;">21</span> <span style="color: #cc66cc;">34</span> <span style="color: #cc66cc;">55</span> <span style="color: #cc66cc;">89</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span></pre></div>
<p>At the USerial home page, you can find <a href="http://nklein.com/software/unet/userial/userial">more complete documentation</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://nklein.com/2011/05/userial-v0-7-2011-05-24-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>USerial &#8212; v0.7.2011.05.24</title>
		<link>http://nklein.com/2011/05/userial-v0-7-2011-05-24-2/</link>
		<comments>http://nklein.com/2011/05/userial-v0-7-2011-05-24-2/#comments</comments>
		<pubDate>Wed, 25 May 2011 04:28:16 +0000</pubDate>
		<dc:creator>pat</dc:creator>
				<category><![CDATA[New Versions]]></category>
		<category><![CDATA[Releases]]></category>
		<category><![CDATA[lisp]]></category>
		<category><![CDATA[userial]]></category>

		<guid isPermaLink="false">http://nklein.com/?p=1726</guid>
		<description><![CDATA[I am releasing a new version of my USerial library. This version cleans up many messes from earlier releases. Unfortunately, in that process, it breaks compatibility with earlier releases. Obtaining Getting the USerial library: The home page: http://nklein.com/software/unet/userial/ The tar-ball: userial_0.7.2011.05.24.tar.gz The GPG signature for the tar-ball: userial_0.7.2011.05.24.tar.gz.asc The main git repository: http://git.nklein.com/lisp/libs/userial.git A browsable [...]]]></description>
			<content:encoded><![CDATA[<p>I am releasing a new version of my <a href="http://nklein.com/software/unet/userial/userial">USerial</a> library. This version cleans up many messes from earlier releases. Unfortunately, in that process, it breaks compatibility with earlier releases.</p>
<h4>Obtaining</h4>
<p>Getting the USerial library:</p>
<ul>
<li>The home page: <a href="http://nklein.com/software/unet/userial/">http://nklein.com/software/unet/userial/</a></li>
<li>The tar-ball: <a href="http://nklein.com/wp-content/uploads/2011/05/userial_0.7.2011.05.24.tar.gz">userial_0.7.2011.05.24.tar.gz</a></li>
<li>The GPG signature for the tar-ball: <a href="http://nklein.com/wp-content/uploads/2011/05/userial_0.7.2011.05.24.tar.gz.asc">userial_0.7.2011.05.24.tar.gz.asc</a></li>
<li>The main git repository: <a href="http://git.nklein.com/lisp/libs/userial.git/">http://git.nklein.com/lisp/libs/userial.git</a></li>
<li>A browsable mirror of the git repository: <a href="http://github.com/nklein/userial/">http://github.com/nklein/userial</a></li>
</ul>
<h4>Differences</h4>
<p>The differences between this version and earlier versions of this library include:</p>
<ul>
<li>Use of <a href="http://common-lisp.net/project/closer/contextl.html">ContextL</a> layered functions instead of CLOS methods</li>
<li>Elimination of <code class="codecolorer lisp default"><span class="lisp"><span style="color: #66cc66;">:</span><span style="color: #555;">buffer</span></span></code> parameter in favor of using the <code class="codecolorer lisp default"><span class="lisp">*buffer*</span></code> special variable</li>
<li>Cleaning up macros which no longer required the <code class="codecolorer lisp default"><span class="lisp"><span style="color: #66cc66;">:</span><span style="color: #555;">buffer</span></span></code> parameter</li>
<li>Serializers for arbitrarily large integers and unsigned integers</li>
<li>Serializer for raw sequence of bytes</li>
<li>New <code class="codecolorer lisp default"><span class="lisp">make-list-serializer</span></code> macro</li>
</ul>
<p>By using ContextL layered functions, one has the ability to define a serializer and/or unserializer in a particular ContextL layer.  This can be used to create new versions of the serializer without losing the ability to use the older version when required.</p>
<p>In the process, I have created macros to assist in creating completely custom serializers.  This both streamlines their definition and should allow any future modifications to the USerial library to fly under the radar.  Code that before looked like this:</p>
<div class="codecolorer-container lisp blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><pre class="lisp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #66cc66;">&#40;</span>defmethod serialize <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>key <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">eql</span> <span style="color: #66cc66;">:</span><span style="color: #555;">foo</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">value</span> foo-struct<span style="color: #66cc66;">&#41;</span>
                      <span style="color: #66cc66;">&amp;</span>key <span style="color: #66cc66;">&#40;</span>buffer userial<span style="color: #66cc66;">:</span>*buffer*<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&amp;</span>amp<span style="color: #808080; font-style: italic;">;allow-other-keys)</span>
  <span style="color: #66cc66;">...</span> some code <span style="color: #66cc66;">...</span>
  buffer<span style="color: #66cc66;">&#41;</span>
&nbsp;
<span style="color: #66cc66;">&#40;</span>defmethod unserialize <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>key <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">eql</span> <span style="color: #66cc66;">:</span><span style="color: #555;">foo</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
                        <span style="color: #66cc66;">&amp;</span>key <span style="color: #66cc66;">&#40;</span>buffer userial<span style="color: #66cc66;">:</span>*buffer*<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&amp;</span>amp<span style="color: #808080; font-style: italic;">;allow-other-keys)</span>
  <span style="color: #66cc66;">&#40;</span>values <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">progn</span> <span style="color: #66cc66;">...</span> some code <span style="color: #66cc66;">...</span><span style="color: #66cc66;">&#41;</span>
          buffer<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span></pre></div>
<p>Should now look like this:</p>
<div class="codecolorer-container lisp blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><pre class="lisp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #66cc66;">&#40;</span>define-serializer <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">:</span><span style="color: #555;">foo</span> <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">value</span> foo-struct<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
  <span style="color: #66cc66;">...</span> some code <span style="color: #66cc66;">...</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
<span style="color: #66cc66;">&#40;</span>define-unserializer <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">:</span><span style="color: #555;">foo</span><span style="color: #66cc66;">&#41;</span>
  <span style="color: #66cc66;">...</span> some code <span style="color: #66cc66;">...</span><span style="color: #66cc66;">&#41;</span></pre></div>
<p>And, when you find you need to add a new version of your <code class="codecolorer lisp default"><span class="lisp"><span style="color: #66cc66;">:</span><span style="color: #555;">foo</span></span></code> serializer but you don&#8217;t want to lose the old one, you can add:</p>
<div class="codecolorer-container lisp blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><pre class="lisp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #66cc66;">&#40;</span>contextl<span style="color: #66cc66;">:</span><span style="color: #555;">deflayer</span> new-version<span style="color: #66cc66;">&#41;</span>
&nbsp;
<span style="color: #66cc66;">&#40;</span>define-serializer <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">:</span><span style="color: #555;">foo</span> <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">value</span> foo-struct<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">:</span><span style="color: #555;">layer</span> new-version<span style="color: #66cc66;">&#41;</span>
  <span style="color: #66cc66;">...</span> some new code <span style="color: #66cc66;">...</span><span style="color: #66cc66;">&#41;</span></pre></div>
<p>Without the <code class="codecolorer lisp default"><span class="lisp"><span style="color: #66cc66;">:</span><span style="color: #555;">buffer</span></span></code> parameter everywhere, code that used to look like this:</p>
<div class="codecolorer-container lisp blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><pre class="lisp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #66cc66;">&#40;</span>serialize* <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">:</span><span style="color: #555;">string</span> aa <span style="color: #66cc66;">:</span><span style="color: #555;">uint8</span> bb<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">:</span><span style="color: #555;">buffer</span> buf<span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#40;</span>buffer-rewind <span style="color: #66cc66;">:</span><span style="color: #555;">buffer</span> buf<span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#40;</span>unserialize-slots* <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">:</span><span style="color: #555;">string</span> <span style="color: #b1b100;">name</span> <span style="color: #66cc66;">:</span><span style="color: #555;">uint8</span> age<span style="color: #66cc66;">&#41;</span> object <span style="color: #66cc66;">:</span><span style="color: #555;">buffer</span> buf<span style="color: #66cc66;">&#41;</span></pre></div>
<p>Should now look like this:</p>
<div class="codecolorer-container lisp blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><pre class="lisp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #66cc66;">&#40;</span>with-buffer buf
  <span style="color: #66cc66;">&#40;</span>serialize* <span style="color: #66cc66;">:</span><span style="color: #555;">string</span> aa <span style="color: #66cc66;">:</span><span style="color: #555;">uint8</span> bb<span style="color: #66cc66;">&#41;</span>
  <span style="color: #66cc66;">&#40;</span>buffer-rewind<span style="color: #66cc66;">&#41;</span>
  <span style="color: #66cc66;">&#40;</span>unserialize-slots* object <span style="color: #66cc66;">:</span><span style="color: #555;">string</span> <span style="color: #b1b100;">name</span> <span style="color: #66cc66;">:</span><span style="color: #555;">uint</span> age<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span></pre></div>
<p>There are now <code class="codecolorer lisp default"><span class="lisp"><span style="color: #66cc66;">:</span><span style="color: #555;">int</span></span></code> and <code class="codecolorer lisp default"><span class="lisp"><span style="color: #66cc66;">:</span><span style="color: #555;">uint</span></span></code> serializers that encode arbitrarily large integers and unsigned integers, respectively.  There is also a serializer that copies a sequence of bytes as is without any prefix or suffix. To unserialize, you either have to provide a buffer of the appropriate length with the <code class="codecolorer lisp default"><span class="lisp"><span style="color: #66cc66;">:</span><span style="color: #555;">output</span></span></code> parameter or provide appropriate <code class="codecolorer lisp default"><span class="lisp"><span style="color: #66cc66;">:</span><span style="color: #555;">start</span></span></code> and <code class="codecolorer lisp default"><span class="lisp"><span style="color: #66cc66;">:</span><span style="color: #555;">end</span></span></code> keywords.</p>
<div class="codecolorer-container lisp blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><pre class="lisp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #66cc66;">&#40;</span>serialize <span style="color: #66cc66;">:</span><span style="color: #555;">raw-bytes</span> uchar-<span style="color: #b1b100;">array</span> <span style="color: #66cc66;">&amp;</span>key <span style="color: #66cc66;">&#40;</span>start <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>
                                       <span style="color: #66cc66;">&#40;</span>end <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">length</span> uchar-<span style="color: #b1b100;">array</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>unserialize <span style="color: #66cc66;">:</span><span style="color: #555;">raw-bytes</span> <span style="color: #66cc66;">&amp;</span>key output
                             <span style="color: #66cc66;">&#40;</span>start <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>
                             <span style="color: #66cc66;">&#40;</span>end <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">length</span> output<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span></pre></div>
<p>And, if you have a serialize/unserialize pair for type <code class="codecolorer lisp default"><span class="lisp"><span style="color: #66cc66;">:</span><span style="color: #555;">foo</span></span></code> you can use the <code class="codecolorer lisp default"><span class="lisp">make-list-serializer</span></code> macro to create a serialize/unserialize pair for a list of items that can be serialized with the <code class="codecolorer lisp default"><span class="lisp"><span style="color: #66cc66;">:</span><span style="color: #555;">foo</span></span></code> serializer.</p>
<div class="codecolorer-container lisp blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><pre class="lisp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #66cc66;">&#40;</span>make-list-serializer <span style="color: #66cc66;">:</span><span style="color: #555;">list-of-uint8</span> <span style="color: #66cc66;">:</span><span style="color: #555;">uint8</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#40;</span>serialize <span style="color: #66cc66;">:</span><span style="color: #555;">list-of-int8</span> '<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">1</span> <span style="color: #cc66cc;">1</span> <span style="color: #cc66cc;">2</span> <span style="color: #cc66cc;">3</span> <span style="color: #cc66cc;">5</span> <span style="color: #cc66cc;">8</span> <span style="color: #cc66cc;">13</span> <span style="color: #cc66cc;">21</span> <span style="color: #cc66cc;">34</span> <span style="color: #cc66cc;">55</span> <span style="color: #cc66cc;">89</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span></pre></div>
<p>At the USerial home page, you can find <a href="http://nklein.com/software/unet/userial/userial">more complete documentation</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://nklein.com/2011/05/userial-v0-7-2011-05-24-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Method Versions &#8212; Retracted</title>
		<link>http://nklein.com/2011/05/method-versions-retracted/</link>
		<comments>http://nklein.com/2011/05/method-versions-retracted/#comments</comments>
		<pubDate>Fri, 20 May 2011 00:11:32 +0000</pubDate>
		<dc:creator>pat</dc:creator>
				<category><![CDATA[Bug Fixes]]></category>
		<category><![CDATA[Releases]]></category>
		<category><![CDATA[lisp]]></category>
		<category><![CDATA[method-versions]]></category>

		<guid isPermaLink="false">http://nklein.com/?p=1714</guid>
		<description><![CDATA[When I wrote the method-versions library, I had read about ContextL and decided that I only wanted a very small subset of it and wanted it to be very easy to use. It turns out that I didn&#8217;t quite understand the complexity-level of ContextL. It is actually very similar to what I had wanted. With [...]]]></description>
			<content:encoded><![CDATA[<p>When I wrote the <a href="http://nklein.com/software/method-versions/">method-versions library</a>, I had read about <a href="http://common-lisp.net/project/closer/contextl.html">ContextL</a> and decided that I only wanted a very small subset of it and wanted it to be very easy to use.  It turns out that I didn&#8217;t quite understand the complexity-level of ContextL.  It is actually very similar to what I had wanted.</p>
<p>With my library, you set up some versions and a variable to track the current version:</p>
<div class="codecolorer-container lisp blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><pre class="lisp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #66cc66;">&#40;</span>method-versions<span style="color: #66cc66;">:</span><span style="color: #555;">define-method-version</span> <span style="color: #66cc66;">:</span><span style="color: #555;">v1</span><span style="color: #66cc66;">.</span>0<span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#40;</span>method-versions<span style="color: #66cc66;">:</span><span style="color: #555;">define-method-version</span> <span style="color: #66cc66;">:</span><span style="color: #555;">v1</span><span style="color: #66cc66;">.</span>1 <span style="color: #66cc66;">:</span><span style="color: #555;">v1</span><span style="color: #66cc66;">.</span>0<span style="color: #66cc66;">&#41;</span>
&nbsp;
<span style="color: #66cc66;">&#40;</span>declaim <span style="color: #66cc66;">&#40;</span>special *protocol-version*<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#40;</span>defparameter *protocol-version* <span style="color: #66cc66;">:</span><span style="color: #555;">v1</span><span style="color: #66cc66;">.</span>0<span style="color: #66cc66;">&#41;</span></pre></div>
<p>In ContextL, you just set up some layers:</p>
<div class="codecolorer-container lisp blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><pre class="lisp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #66cc66;">&#40;</span>contextl<span style="color: #66cc66;">:</span><span style="color: #555;">deflayer</span> <span style="color: #66cc66;">:</span><span style="color: #555;">v1</span><span style="color: #66cc66;">.</span>0<span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#40;</span>contextl<span style="color: #66cc66;">:</span><span style="color: #555;">deflayer</span> <span style="color: #66cc66;">:</span><span style="color: #555;">v1</span><span style="color: #66cc66;">.</span>1 <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">:</span><span style="color: #555;">v1</span><span style="color: #66cc66;">.</span>0<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span></pre></div>
<p>In my library, you then set up a generic function that uses a special method combination that keys off of the special variable:</p>
<div class="codecolorer-container lisp blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><pre class="lisp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #66cc66;">&#40;</span>defgeneric send-cmd <span style="color: #66cc66;">&#40;</span>cmd<span style="color: #66cc66;">&#41;</span>
  <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">:</span><span style="color: #555;">method-combination</span> method-versions<span style="color: #66cc66;">:</span><span style="color: #555;">method-versions-method-combination</span>
                       *protocol-version*<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span></pre></div>
<p>In ContextL, you declare a layered function:</p>
<div class="codecolorer-container lisp blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><pre class="lisp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #66cc66;">&#40;</span>contextl<span style="color: #66cc66;">:</span><span style="color: #555;">define-layered-</span><span style="color: #b1b100;">function</span> <span style="color: #66cc66;">&#40;</span>cmd<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span></pre></div>
<p>In my library, you then declare different methods using the version as a method qualifier.</p>
<div class="codecolorer-container lisp blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><pre class="lisp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #66cc66;">&#40;</span>defmethod send-cmd <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>cmd login-cmd<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
  <span style="color: #66cc66;">&#40;</span>send-string <span style="color: #66cc66;">&#40;</span>login-<span style="color: #b1b100;">name</span> cmd<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
  <span style="color: #66cc66;">&#40;</span>send-string <span style="color: #66cc66;">&#40;</span>login-password cmd<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
<span style="color: #66cc66;">&#40;</span>defmethod send-cmd <span style="color: #66cc66;">:</span><span style="color: #555;">v1</span><span style="color: #66cc66;">.</span>0 <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>cmd login-cmd<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
  <span style="color: #66cc66;">&#40;</span>send-string <span style="color: #66cc66;">&#40;</span>login-<span style="color: #b1b100;">name</span> cmd<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
  <span style="color: #66cc66;">&#40;</span>send-string <span style="color: #66cc66;">&#40;</span>login-password cmd<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
  <span style="color: #66cc66;">&#40;</span>send-string <span style="color: #66cc66;">&#40;</span>login-location cmd<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span></pre></div>
<p>In ContextL, you declare layered methods specifying which layer the functions belong to:</p>
<div class="codecolorer-container lisp blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><pre class="lisp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #66cc66;">&#40;</span>contextl<span style="color: #66cc66;">:</span><span style="color: #555;">define-layered-method</span> send-cmd <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>cmd login-cmd<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
  <span style="color: #66cc66;">&#40;</span>send-string <span style="color: #66cc66;">&#40;</span>login-<span style="color: #b1b100;">name</span> cmd<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
  <span style="color: #66cc66;">&#40;</span>send-string <span style="color: #66cc66;">&#40;</span>login-password cmd<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
<span style="color: #66cc66;">&#40;</span>contextl<span style="color: #66cc66;">:</span><span style="color: #555;">define-layered-method</span> send-cmd <span style="color: #66cc66;">:</span><span style="color: #555;">in</span> <span style="color: #66cc66;">:</span><span style="color: #555;">v1</span><span style="color: #66cc66;">.</span>0 <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>cmd login-cmd<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
  <span style="color: #66cc66;">&#40;</span>send-string <span style="color: #66cc66;">&#40;</span>login-<span style="color: #b1b100;">name</span> cmd<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
  <span style="color: #66cc66;">&#40;</span>send-string <span style="color: #66cc66;">&#40;</span>login-password cmd<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
  <span style="color: #66cc66;">&#40;</span>send-string <span style="color: #66cc66;">&#40;</span>login-location cmd<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span></pre></div>
<p>In my library, you set your special variable appropriately and invoke the method:</p>
<div class="codecolorer-container lisp blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><pre class="lisp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">let</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>*protocol-version* <span style="color: #66cc66;">:</span><span style="color: #555;">v1</span><span style="color: #66cc66;">.</span>1<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
  <span style="color: #66cc66;">&#40;</span>send-cmd cmd<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span></pre></div>
<p>In ContextL, you declare which layer you want to be active when you go to invoke the method:</p>
<div class="codecolorer-container lisp blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><pre class="lisp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #66cc66;">&#40;</span>contextl<span style="color: #66cc66;">:</span><span style="color: #555;">with-active-layers</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">:</span><span style="color: #555;">v1</span><span style="color: #66cc66;">.</span>1<span style="color: #66cc66;">&#41;</span>
  <span style="color: #66cc66;">&#40;</span>send-cmd cmd<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span></pre></div>
<p>My library does not let you specify other method qualifiers like <code class="codecolorer lisp default"><span class="lisp"><span style="color: #66cc66;">:</span><span style="color: #555;">around</span></span></code> or <code class="codecolorer lisp default"><span class="lisp"><span style="color: #66cc66;">:</span><span style="color: #555;">after</span></span></code>.  ContextL does.</p>
<p>I am going to leave my library published because I think it is a reasonably understandable, yet non-trivial, use of non-standard method combinations.  However, I am going to end up using ContextL for the projects that I had intended for my library.</p>
]]></content:encoded>
			<wfw:commentRss>http://nklein.com/2011/05/method-versions-retracted/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Method Versions &#8212; v0.1.2011.05.18</title>
		<link>http://nklein.com/2011/05/method-versions-v0-1-2011-05-18-2/</link>
		<comments>http://nklein.com/2011/05/method-versions-v0-1-2011-05-18-2/#comments</comments>
		<pubDate>Thu, 19 May 2011 04:00:50 +0000</pubDate>
		<dc:creator>pat</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[New Versions]]></category>
		<category><![CDATA[Releases]]></category>
		<category><![CDATA[lisp]]></category>
		<category><![CDATA[method-versions]]></category>

		<guid isPermaLink="false">http://nklein.com/?p=1702</guid>
		<description><![CDATA[Edit: After re-reading some of the ContextL papers, I believe that I am actually just going to use ContextL as it&#8217;s a much more flexible superset of this library. I will probably still keep this library published as an example of a non-trivial, but glarkable, method combination. I am releasing a new library that allows [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p><b>Edit: </b> After re-reading some of the ContextL papers, I believe that I am actually just going to use ContextL as it&#8217;s a much more flexible superset of this library.  I will probably still keep this library published as an example of a non-trivial, but glarkable, method combination.</p></blockquote>
<p>I am releasing a new library that allows one to dispatch generic methods based on the value of a global parameter.</p>
<p>There are situations where one might like to dispatch a method on some information other than the required parameters of the method.  For many situations, it is sufficient to switch between those methods based on some external parameter.  The <a href="http://nklein.com/software/method-versions/">method-versions</a> library allows one to do just that.</p>
<h4><a name="obtaining">Obtaining</a></h4>
<ul>
<li>The home page: <a href="http://nklein.com/software/method-versions/">http://nklein.com/software/method-versions/</a></li>
<li>The tar-ball: <a href="http://nklein.com/wp-content/uploads/2011/05/method-versions_0.1.2011.05.18.tar.gz">method-versions_0.1.2011.05.18.tar.gz</a></li>
<li>The GPG signature for the tar-ball: <a href="http://nklein.com/wp-content/uploads/2011/05/method-versions_0.1.2011.05.18.tar.gz.asc">method-versions_0.1.2011.05.18.tar.gz.asc</a></li>
<li>The main git repository: <a href="http://git.nklein.com/lisp/libs/method-versions.git">http://git.nklein.com/lisp/libs/method-versions.git</a></li>
<li>A browsable mirror of the git repository: <a href="http://github.com/nklein/method-versions">http://github.com/nklein/method-versions</a></li>
</ul>
<h4><a name="internationalization">Internationalization Example</a></h4>
<p>In this example, we do a silly form of internationalization. To that end, we will use English as the default language and define some other languages.</p>
<div class="codecolorer-container lisp blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><pre class="lisp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"> <span style="color: #66cc66;">&#40;</span>method-versions<span style="color: #66cc66;">:</span><span style="color: #555;">define-method-version</span> latin<span style="color: #66cc66;">&#41;</span>
 <span style="color: #66cc66;">&#40;</span>method-versions<span style="color: #66cc66;">:</span><span style="color: #555;">define-method-version</span> pig-latin<span style="color: #66cc66;">&#41;</span>
 <span style="color: #66cc66;">&#40;</span>method-versions<span style="color: #66cc66;">:</span><span style="color: #555;">define-method-version</span> french latin<span style="color: #66cc66;">&#41;</span>
 <span style="color: #66cc66;">&#40;</span>method-versions<span style="color: #66cc66;">:</span><span style="color: #555;">define-method-version</span> spanish latin<span style="color: #66cc66;">&#41;</span></pre></div>
<p>We will prepare a language parameter and a welcome method that is versioned on the language.</p>
<div class="codecolorer-container lisp blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><pre class="lisp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"> <span style="color: #66cc66;">&#40;</span>declaim <span style="color: #66cc66;">&#40;</span>special *language*<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
 <span style="color: #66cc66;">&#40;</span>defparameter *language* <span style="color: #b1b100;">nil</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
 <span style="color: #66cc66;">&#40;</span>defgeneric welcome <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
   <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">:</span><span style="color: #555;">method-combination</span> method-versions<span style="color: #66cc66;">:</span><span style="color: #555;">method-version-method-combination</span>
                        *language*<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span></pre></div>
<p>And, we define welcome methods for the various languages (accidentally forgetting <code class="codecolorer lisp default"><span class="lisp">spanish</span></code>).</p>
<div class="codecolorer-container lisp blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><pre class="lisp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"> <span style="color: #66cc66;">&#40;</span>defmethod welcome <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">:</span><span style="color: #555;">welcome</span><span style="color: #66cc66;">&#41;</span>
 <span style="color: #66cc66;">&#40;</span>defmethod welcome <span style="color: #66cc66;">:</span><span style="color: #555;">latin</span>     <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">:</span><span style="color: #555;">velkominum</span><span style="color: #66cc66;">&#41;</span>
 <span style="color: #66cc66;">&#40;</span>defmethod welcome <span style="color: #66cc66;">:</span><span style="color: #555;">pig-latin</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">:</span><span style="color: #555;">elcomeway</span><span style="color: #66cc66;">&#41;</span>
 <span style="color: #66cc66;">&#40;</span>defmethod welcome <span style="color: #66cc66;">:</span><span style="color: #555;">french</span>    <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">:</span><span style="color: #555;">bonjour</span><span style="color: #66cc66;">&#41;</span></pre></div>
<p>Then, we will try each of the languages in turn.</p>
<div class="codecolorer-container lisp blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><pre class="lisp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"> <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">mapcar</span> #'<span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">lambda</span> <span style="color: #66cc66;">&#40;</span>ll<span style="color: #66cc66;">&#41;</span>
             <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">let</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>*language* ll<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
               <span style="color: #66cc66;">&#40;</span>welcome<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: #b1b100;">nil</span> <span style="color: #66cc66;">:</span><span style="color: #555;">latin</span> <span style="color: #66cc66;">:</span><span style="color: #555;">pig-latin</span> <span style="color: #66cc66;">:</span><span style="color: #555;">french</span> <span style="color: #66cc66;">:</span><span style="color: #555;">spanish</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
 <span style="color: #66cc66;">=&gt;</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">:</span><span style="color: #555;">welcome</span> <span style="color: #66cc66;">:</span><span style="color: #555;">velkominum</span> <span style="color: #66cc66;">:</span><span style="color: #555;">elcomeway</span> <span style="color: #66cc66;">:</span><span style="color: #555;">bonjour</span> <span style="color: #66cc66;">:</span><span style="color: #555;">velkominum</span><span style="color: #66cc66;">&#41;</span></pre></div>
]]></content:encoded>
			<wfw:commentRss>http://nklein.com/2011/05/method-versions-v0-1-2011-05-18-2/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

