<?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>孩子气 &#124; C++, Lua, 大连,程序员 &#187; lua</title>
	<atom:link href="http://sunxiunan.com/?feed=rss2&#038;cat=21" rel="self" type="application/rss+xml" />
	<link>http://sunxiunan.com</link>
	<description>sunxiunan</description>
	<lastBuildDate>Mon, 06 Sep 2010 15:12:27 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Lua协程实现Fibonacci算法</title>
		<link>http://sunxiunan.com/?p=1689</link>
		<comments>http://sunxiunan.com/?p=1689#comments</comments>
		<pubDate>Wed, 25 Aug 2010 03:09:48 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[lua]]></category>
		<category><![CDATA[lua 协程]]></category>

		<guid isPermaLink="false">http://sunxiunan.com/?p=1689</guid>
		<description><![CDATA[费波拉且数的算法如图所示： 所以a和b分别保存了前两次的结果，每次for循环调用generator都从yield这一行代码恢复然后进行a, b = b, a+b操作。然后判断a是否小于等于n决定返回结果。 如果不用coroutine.wrap，我们可以这样写，效果是一样的，代码稍显啰嗦：]]></description>
			<content:encoded><![CDATA[<p><a href="http://sunxiunan.com/media/LuaFibonacci_9824/image.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://sunxiunan.com/media/LuaFibonacci_9824/image_thumb.png" width="480" height="251" /></a> </p>
<p>费波拉且数的算法如图所示：</p>
<p><a href="http://sunxiunan.com/media/LuaFibonacci_9824/image_3.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://sunxiunan.com/media/LuaFibonacci_9824/image_thumb_3.png" width="350" height="95" /></a> </p>
<p>所以a和b分别保存了前两次的结果，每次for循环调用generator都从yield这一行代码恢复然后进行a, b = b, a+b操作。然后判断a是否小于等于n决定返回结果。</p>
<p>如果不用coroutine.wrap，我们可以这样写，效果是一样的，代码稍显啰嗦：</p>
<p><a href="http://sunxiunan.com/media/LuaFibonacci_9824/image_4.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://sunxiunan.com/media/LuaFibonacci_9824/image_thumb_4.png" width="605" height="411" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://sunxiunan.com/?feed=rss2&amp;p=1689</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Lua Unicode （Wiki翻译）</title>
		<link>http://sunxiunan.com/?p=1681</link>
		<comments>http://sunxiunan.com/?p=1681#comments</comments>
		<pubDate>Mon, 16 Aug 2010 09:18:54 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[lua]]></category>
		<category><![CDATA[unicode]]></category>

		<guid isPermaLink="false">http://sunxiunan.com/?p=1681</guid>
		<description><![CDATA[http://lua-users.org/wiki/LuaUnicode 这里尝试着回答一下LuaFaq问题： 我可以使用Unicode字符串么？或者，Lua支持Unicode么？ 简言之，可以，不支持。Lua只有极为精简的支持和足够的辅助功能，就没有其它的了。Unicode是一个庞大而复杂的标准，像是“Lua是否支持Unicode”是比较模糊地问题。 一些问题如下： 我可以存取Unicode字符串么？ 我的Lua程序能用Unicode写么？ 我可以比较Unicode字符串是否相同么？ 字符串排序。 模式匹配。 我可以取得一个Unicode字符串的长度么？ 支持括号型匹配，双向打印，随意的字符串组合以及各种高品质排版技术中产生的问题。 Lua字符串使用8-bit，所以简单的应用是支持的（比如存取操作）。但对于其他复杂操作没有内建支持。想知道更多故事，往下看。 Unicode字符串和Lua字符串 一个Lua字符串是一个至少8bit值的任意组合；可以直接映射到C编译器中的char类型（可能会比8bits更宽，但是一定会保证有8bits）。Lua没有保留任意字符，包括NUL。这意味着你可以成功地在Lua中存储UTF-8字符串。 注意UTF-8只是存储Unicode字符串的一种可能。还有其他编码模式，包括UTF-16和UTF-32以及它们的大端、小端变体。无论如何，所有这些都仅仅是8位字节的组合，可以毫无问题的存储到Lua字符串中。 在Lua中字符串的输入输出（使用IO库）使用C的stdio库，ANSI C不需要stdio库来处理任意8位字节顺序，除非是二进制模式。更进一步说，在非二进制模式，一些8位字节顺序可以转换到其他字符（为了处理不同平台上的换行符）。 这可能影响到处理非二进制的而且不是UTF-8格式的Unicode字符串文件输入输出。UTF-8字符串可能还是安全的，因为UTF-8不使用控制字符如\r \n作为多字节解析的一部分。而且这也不是一定的。如果你需要个确定答案，你应该使用二进制模式输入输出（binary-mode）。（如果你使用二进制模式，行结尾符将不会被转换）。 Unix文件输入输出很长时间里都是8字节整的。如果你不关心可移植性，仅仅在Unix或者类Unix系统上工作，可以完全不用担心前面提到的。 如果你使用Unicode是限制在传送字符串到外部支持Unicode的程序员，应该是不用担心的。例如，你应该可以从数据库取得一个Unicode字符串传递到一个识别Unicode的图形库中。但是也看看下面关于模式匹配和字符串等同比较的章节。 Unicode Lua 程序 字面型Unicode字符串可以出现在你的Lua程序组，UTF-8编码的字符串可以直接用8位字符形式或者使用\ddd语法（注意ddd是一个十进制数）。无论如何没有编码多字节顺序的功能（比如\U+20B4）；你可能不得不手动把它们编码成UTF-8格式或者以正确的大端或小端顺序塞进单独的8位字节数值中（针对UTF-16或者UTF-32）。 如果你不是使用某个char比8位更长字节的操作系统，就不能用任意的Unicode字符作为Lua标示符（变量名或者类似）。你可能使用ANSI以外的8位字符，Lua使用C函数isalpha和isalnum来辨别正确的可作为标示符的字符，所以这与当前locale配置有关。实话讲，使用ANSI以外的的字符做标示符不是一个好主意，因为你的程序可能没法在标准C locale下编译。 比较和排序 Lua字符串比较（使用==操作符）是通过逐个字节比较完成。这意味着==仅仅可以用来比较特殊的等同性，就是Unicode字符已经被正常化为正常可能之一（http://www.unicode.org/faq/normalization.html）。标准Lua库不提供任何正常化Unicode字符串的能力。相应的，非正常化的Unicode字符串也不能被可靠的用作table的key。 如果你想用Unicode类型的字符串等同比较，或者使用Unicode作为table的key，你不能保证你的字符串一定被正常化，然后你不得不自己写或者寻找一个正常化函数，这是一个很重要的练习！ Lua字符串比较操作符（&#60;和&#60;=）使用C语言函数strcoll，这个函数依赖于locale配置。这意味着两个字符串随着locale不同会得到不同的结果。例如，字符串使用西班牙语传统排序与威尔士语排序结果是不一样的。 也许你的操作系统实现了你想要的排序算法，这时候你可以使用它们，否则你可能要自己写函数来对Unicode字符串排序。这是一个更重要的练习。 UTF-8被设计成一个8位字节序的简单逐位比较可以得到同样的结果。UTF-32也是正确的，但是我不知道什么系统使用这个编码方式。不幸的是，简单的逐位比较没有被用作任何语言的排列顺序。 模式匹配 Lua的模式匹配的工作方式也是逐个字节的。通常情况下，这对于Unicode的模式匹配没有用处。即使有时候程序以你预想的方式工作了。例如，&#34;%u&#34;将不能匹配所有Unicode大写字符。你能匹配正常化后的Unicode字符串中的单个Unicode字符，但是你可能也担心字符串顺序。如果没有后续合并字符串，&#34;a&#34;将匹配一个UTF-8字符中的字符a。在UTF-16LE中你能匹配&#34;a%z&#34;。（记住你不能使用\0在Lua模式中） 长度和字符串索引 如果你想知道一个Unicode字符的长度，根据情况不同你会得到不同答案。 如果你想知道一个字符串占据多少个字节，比如你想拷贝到某个buffer中，现有的string.len函数可以工作。 你可能想知道Unicode字符串有多少字符。根据被使用的编码，一个单一的Unicode字符占用4个字节。只有UTF-32LE和UTF-32BE是常数长度编码（每个字符四字节）；UTF-32是一个常数长度编码但是第一个元素应该是”字节序标记”。这不应该被看做字符（UTF-32和变体是最新版本Unicode4.0的一部分）。 一些UTF-16的实现确保所有字符都是两字节长，但是从Unicode3.0版本以后就不是这样。 很高兴的是UTF-8被设计成很容易计算Unicode字符串中符号个数；仅仅计算0&#215;00到0x7f或者0xC2到0xF4范围内的八位字节数字个数。这些是UTF-8字符码的开始。0xC0, 0xC1, 0xF5到0xFF不能用于构成UTF-8字节序；八位字节在0&#215;80到0xBF可以仅仅出现在第二个或者多位编码后面部分。记住你不能使用\0在Lua模式中。 例如，你想使用接下来的代码计算UTF-8字符个数，（对于计算某些非法字符，这是不正确的） local _, count = string.gsub(unicode_string, &#34;[^\128-\193]&#34;, &#34;&#34;) 如果你想知道一个Unicode字符串占据多少打印列（当你使用固定宽度字体），又有不同的回答了。这是因为某些Unicode字符没有一个打印宽度，而另外一些有两倍的打印宽度。合并字符被用于给其他字符加重音，通常打印时不占据额外空间。 所以不同情况下至少有三种不同的长度可能。Lua提供了一种string.len，而其它你需要自己写函数。 有一个类似的问题就是通过位置索引字符串某个字符。string.sub(s, [...]]]></description>
			<content:encoded><![CDATA[<p><a title="http://lua-users.org/wiki/LuaUnicode" href="http://lua-users.org/wiki/LuaUnicode">http://lua-users.org/wiki/LuaUnicode</a></p>
<p>这里尝试着回答一下LuaFaq问题：</p>
<p><strong>我可以使用Unicode字符串么？或者，Lua支持Unicode么？</strong></p>
<p>简言之，可以，不支持。Lua只有极为精简的支持和足够的辅助功能，就没有其它的了。Unicode是一个庞大而复杂的标准，像是“Lua是否支持Unicode”是比较模糊地问题。</p>
<p>一些问题如下：</p>
<p>我可以存取Unicode字符串么？</p>
<p>我的Lua程序能用Unicode写么？</p>
<p>我可以比较Unicode字符串是否相同么？</p>
<p>字符串排序。</p>
<p>模式匹配。</p>
<p>我可以取得一个Unicode字符串的长度么？</p>
<p>支持括号型匹配，双向打印，随意的字符串组合以及各种高品质排版技术中产生的问题。</p>
<p>Lua字符串使用8-bit，所以简单的应用是支持的（比如存取操作）。但对于其他复杂操作没有内建支持。想知道更多故事，往下看。</p>
<p><strong>Unicode字符串和Lua字符串</strong></p>
<p>一个Lua字符串是一个至少8bit值的任意组合；可以直接映射到C编译器中的char类型（可能会比8bits更宽，但是一定会保证有8bits）。Lua没有保留任意字符，包括NUL。这意味着你可以成功地在Lua中存储UTF-8字符串。</p>
<p>注意UTF-8只是存储Unicode字符串的一种可能。还有其他编码模式，包括UTF-16和UTF-32以及它们的大端、小端变体。无论如何，所有这些都仅仅是8位字节的组合，可以毫无问题的存储到Lua字符串中。</p>
<p>在Lua中字符串的输入输出（使用IO库）使用C的stdio库，ANSI C不需要stdio库来处理任意8位字节顺序，除非是二进制模式。更进一步说，在非二进制模式，一些8位字节顺序可以转换到其他字符（为了处理不同平台上的换行符）。</p>
<p>这可能影响到处理非二进制的而且不是UTF-8格式的Unicode字符串文件输入输出。UTF-8字符串可能还是安全的，因为UTF-8不使用控制字符如\r \n作为多字节解析的一部分。而且这也不是一定的。如果你需要个确定答案，你应该使用二进制模式输入输出（binary-mode）。（如果你使用二进制模式，行结尾符将不会被转换）。</p>
<p>Unix文件输入输出很长时间里都是8字节整的。如果你不关心可移植性，仅仅在Unix或者类Unix系统上工作，可以完全不用担心前面提到的。</p>
<p>如果你使用Unicode是限制在传送字符串到外部支持Unicode的程序员，应该是不用担心的。例如，你应该可以从数据库取得一个Unicode字符串传递到一个识别Unicode的图形库中。但是也看看下面关于模式匹配和字符串等同比较的章节。</p>
<p><strong>Unicode Lua 程序</strong></p>
<p>字面型Unicode字符串可以出现在你的Lua程序组，UTF-8编码的字符串可以直接用8位字符形式或者使用\ddd语法（注意ddd是一个十进制数）。无论如何没有编码多字节顺序的功能（比如\U+20B4）；你可能不得不手动把它们编码成UTF-8格式或者以正确的大端或小端顺序塞进单独的8位字节数值中（针对UTF-16或者UTF-32）。</p>
<p>如果你不是使用某个char比8位更长字节的操作系统，就不能用任意的Unicode字符作为Lua标示符（变量名或者类似）。你可能使用ANSI以外的8位字符，Lua使用C函数isalpha和isalnum来辨别正确的可作为标示符的字符，所以这与当前locale配置有关。实话讲，使用ANSI以外的的字符做标示符不是一个好主意，因为你的程序可能没法在标准C locale下编译。</p>
<p><strong>比较和排序</strong></p>
<p>Lua字符串比较（使用==操作符）是通过逐个字节比较完成。这意味着==仅仅可以用来比较特殊的等同性，就是Unicode字符已经被正常化为正常可能之一（<a title="http://www.unicode.org/faq/normalization.html" href="http://www.unicode.org/faq/normalization.html">http://www.unicode.org/faq/normalization.html</a>）。标准Lua库不提供任何正常化Unicode字符串的能力。相应的，非正常化的Unicode字符串也不能被可靠的用作table的key。</p>
<p>如果你想用Unicode类型的字符串等同比较，或者使用Unicode作为table的key，你不能保证你的字符串一定被正常化，然后你不得不自己写或者寻找一个正常化函数，这是一个很重要的练习！</p>
<p>Lua字符串比较操作符（&lt;和&lt;=）使用C语言函数strcoll，这个函数依赖于locale配置。这意味着两个字符串随着locale不同会得到不同的结果。例如，字符串使用西班牙语传统排序与威尔士语排序结果是不一样的。</p>
<p>也许你的操作系统实现了你想要的排序算法，这时候你可以使用它们，否则你可能要自己写函数来对Unicode字符串排序。这是一个更重要的练习。</p>
<p>UTF-8被设计成一个8位字节序的简单逐位比较可以得到同样的结果。UTF-32也是正确的，但是我不知道什么系统使用这个编码方式。不幸的是，简单的逐位比较没有被用作任何语言的排列顺序。</p>
<p><strong>模式匹配</strong></p>
<p>Lua的模式匹配的工作方式也是逐个字节的。通常情况下，这对于Unicode的模式匹配没有用处。即使有时候程序以你预想的方式工作了。例如，&quot;%u&quot;将不能匹配所有Unicode大写字符。你能匹配正常化后的Unicode字符串中的单个Unicode字符，但是你可能也担心字符串顺序。如果没有后续合并字符串，&quot;a&quot;将匹配一个UTF-8字符中的字符a。在UTF-16LE中你能匹配&quot;a%z&quot;。（记住你不能使用\0在Lua模式中）</p>
<p><strong>长度和字符串索引</strong></p>
<p>如果你想知道一个Unicode字符的长度，根据情况不同你会得到不同答案。</p>
<p>如果你想知道一个字符串占据多少个字节，比如你想拷贝到某个buffer中，现有的string.len函数可以工作。</p>
<p>你可能想知道Unicode字符串有多少字符。根据被使用的编码，一个单一的Unicode字符占用4个字节。只有UTF-32LE和UTF-32BE是常数长度编码（每个字符四字节）；UTF-32是一个常数长度编码但是第一个元素应该是”字节序标记”。这不应该被看做字符（UTF-32和变体是最新版本Unicode4.0的一部分）。</p>
<p>一些UTF-16的实现确保所有字符都是两字节长，但是从Unicode3.0版本以后就不是这样。</p>
<p>很高兴的是UTF-8被设计成很容易计算Unicode字符串中符号个数；仅仅计算0&#215;00到0x7f或者0xC2到0xF4范围内的八位字节数字个数。这些是UTF-8字符码的开始。0xC0, 0xC1, 0xF5到0xFF不能用于构成UTF-8字节序；八位字节在0&#215;80到0xBF可以仅仅出现在第二个或者多位编码后面部分。记住你不能使用\0在Lua模式中。</p>
<p>例如，你想使用接下来的代码计算UTF-8字符个数，（对于计算某些非法字符，这是不正确的）</p>
<pre>local _, count = string.gsub(unicode_string, &quot;[^\128-\193]&quot;, &quot;&quot;)</pre>
<p>如果你想知道一个Unicode字符串占据多少打印列（当你使用固定宽度字体），又有不同的回答了。这是因为某些Unicode字符没有一个打印宽度，而另外一些有两倍的打印宽度。合并字符被用于给其他字符加重音，通常打印时不占据额外空间。</p>
<p>所以不同情况下至少有三种不同的长度可能。Lua提供了一种string.len，而其它你需要自己写函数。</p>
<p>有一个类似的问题就是通过位置索引字符串某个字符。string.sub(s, -3)会返回最后三个字节，但未必会返回最后三个字符。</p>
<p>你可能使用接下来代码段枚举UTF-8字节序：</p>
<pre>

 for uchar in string.gfind(ustring, &quot;([%z\1-\127\194-\244][\128-\191]*)&quot;) 

&#160; do -- something 

end
</pre>
<h4>More sophisticated issues</h4>
<p>As you might have guessed by now, Lua provides no support for things like bidirectional printing or the proper formatting of Thai accents. Normally such things will be taken care of by a graphics or typography library. It would of course be possible to interface to such a library that did these things if you had access to one. </p>
<p>There is a little string-like package <a href="http://luaforge.net/projects/sln/">[slnunicode]</a> with upper/lower, len/sub and pattern matching for UTF-8. </p>
<p>See <a href="http://lua-users.org/wiki/ValidateUnicodeString">ValidateUnicodeString</a> for a smaller library. </p>
<p><a href="http://luaforge.net/projects/icu-lua/">[ICU4Lua]</a> is a Lua binding to ICU (International Components for Unicode <a href="http://en.wikipedia.org/wiki/International_Components_for_Unicode">[1]</a>), an open-source library originally developed by IBM. </p>
<p>See <a href="http://lua-users.org/wiki/UnicodeIdentifers">UnicodeIdentifers</a> for platform independent Unicode Lua programs. </p>
]]></content:encoded>
			<wfw:commentRss>http://sunxiunan.com/?feed=rss2&amp;p=1681</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>static link luasocket into lua with VC2010 under windows</title>
		<link>http://sunxiunan.com/?p=1680</link>
		<comments>http://sunxiunan.com/?p=1680#comments</comments>
		<pubDate>Fri, 06 Aug 2010 13:55:01 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[lua]]></category>

		<guid isPermaLink="false">http://sunxiunan.com/?p=1680</guid>
		<description><![CDATA[1, download lua source code from luabinary project (it includes VC2008 project file). Unzip it to one folder. 2, download luasocket latest code. Unzip it to the folder we create in step1. 3, open lua solution file with vc2010 (I think VC2008 should be OK too). try to build it. Should be successful. 4, add [...]]]></description>
			<content:encoded><![CDATA[<p>1, download lua source code from luabinary project (it includes VC2008 project file). Unzip it to one folder.</p>
<p>2, download luasocket latest code. Unzip it to the folder we create in step1.</p>
<p>3, open lua solution file with vc2010 (I think VC2008 should be OK too). try to build it. Should be successful.</p>
<p>4, add all *.h *.c file of luasocket into the project. Remove following from project: usocket.h usocket.c unix.h unix.c. They are used by unix OS.</p>
<p>5, Modify the project setting. </p>
<p>preprocessor definitions look like: WIN32;_WIN32LUASOCKET_EXPORTS;LUASOCKET_DEBUG;LUASOCKET_API=__declspec(dllexport);NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</p>
<p>and add “Ws2_32.lib;”into library.</p>
<p>6, insert</p>
<pre>&#160; {&quot;mime&quot;, luaopen_mime_core},&#160; {&quot;socket&quot;, luaopen_socket_core},</pre>
<p>into luaL_Reg lualibs[] of linit.c file.</p>
<p>add two extern function declaration.</p>
<pre>int luaopen_mime_core (lua_State *L);int luaopen_socket_core (lua_State *L);</pre>
<p>7, build.</p>
<p>8, change socket.lua under luasocket from require(&quot;socket.core&quot;) to require(&quot;socket&quot;) , change mime.lua, from require(&quot;mime.core&quot;) to require(&quot;mime&quot;)</p>
<p>9, in your test script, for example the testclnt.lua in luasocket/example, add this line </p>
<p>loadfile(&quot;socket.lua&quot;)() </p>
<p>before socket = require(&quot;socket&quot;);</p>
<p>10, run the test. Everything should be OK now.</p>
<p><a title="http://comments.gmane.org/gmane.comp.lang.lua.general/67646" href="http://comments.gmane.org/gmane.comp.lang.lua.general/67646">http://comments.gmane.org/gmane.comp.lang.lua.general/67646</a></p>
<p>&#160;</p>
<pre>

&#160;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://sunxiunan.com/?feed=rss2&amp;p=1680</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>【译文】比较Lua协程与Python生成器</title>
		<link>http://sunxiunan.com/?p=1654</link>
		<comments>http://sunxiunan.com/?p=1654#comments</comments>
		<pubDate>Fri, 11 Jun 2010 02:41:30 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[lua]]></category>
		<category><![CDATA[Lua协程]]></category>

		<guid isPermaLink="false">http://sunxiunan.com/?p=1654</guid>
		<description><![CDATA[Translate from： http://lua-users.org/wiki/LuaCoroutinesVersusPythonGenerators &#8212;&#8212;&#8212;&#8212;&#8212;&#8212; Javascript1.7版有一个非常类似Python生成器(generator)的特性；而类似Lua协程风格的变体在经过长期讨论以后被拒绝（参考http://www.neilmix.com/2007/02/07/threading-in-javascript-17/ ） Python生成器与Lua协程有什么不同之处？Lua最重要的特性，coroutine.yield()是个一般函数，可以在coroutine.resume()动态扩展的任意位置被调用，限制是你不能yield操作C回调函数（除非你使用了Coco库）。在Python中，yield是一个语法，只能在生成器（generator）的语句体里存在。 这意味着Python生成器必须写成生成器形式，不能分解成更小的函数，也不能递归调用自身。你可以通过一个链的形式实现，有封讨论组的邮件http://mail.python.org/pipermail/python-list/2005-August/335545.html 描述了这种机制： 在Lua中，我们可以写神秘的（agnostic）inorder函数作为高阶函数（higher-order）。 这个Lua函数可以用作for loop里面的枚举器： 或者是类似foreach函数排序： inorder(print, t) 我试图尽量简化递归型生成器的比较，写了一些简单程序生成infinite ruler function（http://www.research.att.com/~njas/sequences/A001511 ）。关于这个函数的一个更有意思的网页是Michael Naylor的http://www.ac.wwu.edu/~mnaylor/abacaba/abacaba.html Ruler function可以写成没有递归的形式。但是这个例子里它需要一些特性如深度优先搜索，所以我们还是看看递归实现方式。程序按顺序生成2 ^ K值，然后把它们加到一系列校验测试中。很容易知道ruler函数中前面2 ^ K个元素的和是2^(K+1) -1。Python内嵌函数及标准库可以很容易完成它；在Lua中，我不得不实现sum和islice函数，幸运的是这并不难。 所以Lua实现如下： Python也非常类似： 这里面递归有些诡异，原因是我们手动改变尾调用为一个for loop，因为Python不支持尾调用，而且原始的尾调用实现使得Python数据更难看。 两个程序都可以通过检查，所以只粘贴一下比较结果。我不相信这仅仅是因为“Lua跑得比Python快”，真正原因应该是协程coroutine更快一些，主要不同的地方是不需要传递值到一系列yield中。 &#160; 译者注： 关于Ruler function，可以参考wiki http://en.wikipedia.org/wiki/Thomae%27s_function （后记，由于这方面知识的缺乏，翻译的非常蹩脚难懂，自己都感觉很难受，希望有达人能提出建议意见） 2010-6-14 Update：感谢云风的留言，修改了一些错误的地方。]]></description>
			<content:encoded><![CDATA[<p>Translate from：</p>
<p><a title="http://lua-users.org/wiki/LuaCoroutinesVersusPythonGenerators" href="http://lua-users.org/wiki/LuaCoroutinesVersusPythonGenerators">http://lua-users.org/wiki/LuaCoroutinesVersusPythonGenerators</a></p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p>Javascript1.7版有一个非常类似Python生成器(generator)的特性；而类似Lua协程风格的变体在经过长期讨论以后被拒绝（参考<a title="http://www.neilmix.com/2007/02/07/threading-in-javascript-17/" href="http://www.neilmix.com/2007/02/07/threading-in-javascript-17/">http://www.neilmix.com/2007/02/07/threading-in-javascript-17/</a> ）</p>
<p>Python生成器与Lua协程有什么不同之处？Lua最重要的特性，coroutine.yield()是个一般函数，可以在coroutine.resume()动态扩展的任意位置被调用，限制是你不能yield操作C回调函数（除非你使用了Coco库）。在Python中，yield是一个语法，只能在生成器（generator）的语句体里存在。</p>
<p>这意味着Python生成器必须写成生成器形式，不能分解成更小的函数，也不能递归调用自身。你可以通过一个链的形式实现，有封讨论组的邮件<a title="http://mail.python.org/pipermail/python-list/2005-August/335545.html" href="http://mail.python.org/pipermail/python-list/2005-August/335545.html">http://mail.python.org/pipermail/python-list/2005-August/335545.html</a> 描述了这种机制：</p>
<p><a href="http://sunxiunan.com/media/LuaPython_A05D/image.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://sunxiunan.com/media/LuaPython_A05D/image_thumb.png" width="360" height="158" /></a> </p>
<p>在Lua中，我们可以写神秘的（agnostic）inorder函数作为高阶函数（higher-order）。</p>
<p><a href="http://sunxiunan.com/media/LuaPython_A05D/image_3.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://sunxiunan.com/media/LuaPython_A05D/image_thumb_3.png" width="272" height="130" /></a> </p>
<p>这个Lua函数可以用作for loop里面的枚举器：</p>
<p><a href="http://sunxiunan.com/media/LuaPython_A05D/image_4.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://sunxiunan.com/media/LuaPython_A05D/image_thumb_4.png" width="522" height="70" /></a> </p>
<p>或者是类似foreach函数排序：</p>
<p>inorder(print, t)</p>
<p>我试图尽量简化递归型生成器的比较，写了一些简单程序生成infinite ruler function（<a title="http://www.research.att.com/~njas/sequences/A001511" href="http://www.research.att.com/~njas/sequences/A001511">http://www.research.att.com/~njas/sequences/A001511</a> ）。关于这个函数的一个更有意思的网页是Michael Naylor的<a title="http://www.ac.wwu.edu/~mnaylor/abacaba/abacaba.html" href="http://www.ac.wwu.edu/~mnaylor/abacaba/abacaba.html">http://www.ac.wwu.edu/~mnaylor/abacaba/abacaba.html</a> </p>
<p>Ruler function可以写成没有递归的形式。但是这个例子里它需要一些特性如深度优先搜索，所以我们还是看看递归实现方式。程序按顺序生成2 ^ K值，然后把它们加到一系列校验测试中。很容易知道ruler函数中前面2 ^ K个元素的和是2^(K+1) -1。Python内嵌函数及标准库可以很容易完成它；在Lua中，我不得不实现sum和islice函数，幸运的是这并不难。</p>
<p>所以Lua实现如下：</p>
<p><a href="http://sunxiunan.com/media/LuaPython_A05D/image_5.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://sunxiunan.com/media/LuaPython_A05D/image_thumb_5.png" width="644" height="411" /></a> </p>
<p>Python也非常类似：</p>
<p><a href="http://sunxiunan.com/media/LuaPython_A05D/image_6.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://sunxiunan.com/media/LuaPython_A05D/image_thumb_6.png" width="648" height="259" /></a> </p>
<p>这里面递归有些诡异，原因是我们手动改变尾调用为一个for loop，因为Python不支持尾调用，而且原始的尾调用实现使得Python数据更难看。</p>
<p>两个程序都可以通过检查，所以只粘贴一下比较结果。我不相信这仅仅是因为“Lua跑得比Python快”，真正原因应该是协程coroutine更快一些，主要不同的地方是不需要传递值到一系列yield中。</p>
<p><a href="http://sunxiunan.com/media/LuaPython_A05D/image_7.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://sunxiunan.com/media/LuaPython_A05D/image_thumb_7.png" width="228" height="268" /></a> </p>
<p>&#160;</p>
<p>译者注：</p>
<p>关于Ruler function，可以参考wiki <a title="http://en.wikipedia.org/wiki/Thomae%27s_function" href="http://en.wikipedia.org/wiki/Thomae%27s_function">http://en.wikipedia.org/wiki/Thomae%27s_function</a></p>
<p>（后记，由于这方面知识的缺乏，翻译的非常蹩脚难懂，自己都感觉很难受，希望有达人能提出建议意见）</p>
<p>2010-6-14 Update：感谢云风的留言，修改了一些错误的地方。</p>
]]></content:encoded>
			<wfw:commentRss>http://sunxiunan.com/?feed=rss2&amp;p=1654</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Lua游戏开发的最基本常识game development common sense</title>
		<link>http://sunxiunan.com/?p=1614</link>
		<comments>http://sunxiunan.com/?p=1614#comments</comments>
		<pubDate>Thu, 29 Apr 2010 03:54:57 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[lua]]></category>
		<category><![CDATA[tech]]></category>

		<guid isPermaLink="false">http://sunxiunan.com/?p=1614</guid>
		<description><![CDATA[国内搞游戏开发的常用脚本语言大致两种（Python与Lua），其中刚入行的游戏开发者都会有类似的问题：Lua该怎么用？谁为主谁为辅？C++与Lua该如何交互？ 最近浏览stackoverflow发现这几个不错的帖子，分享给大家： http://stackoverflow.com/questions/2674462/lua-and-c-separation-of-duties Lua与C的责任分配问题。 http://stackoverflow.com/questions/2685636/lua-game-state-and-game-loop 游戏大循环（game loop）该如何维护？ &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; 另外国内网易云风的博客上也零零散散有些内容，可以参考。 我不是游戏开发业者，所以也不好发表什么建议。但是我想比较重要的一点，也是在程序设计理念上一直强调的一点是：你要知道你要做什么，你想完成什么功能需求。 有些人话都说不清楚，就想搞游戏设计开发。脑子里都是浆糊，怎么可能设计出清晰的程序逻辑。找一支笔一个本子，先把你的需求想法列出来，画个交互关系图，把时序逻辑理清了，该如何设计如何开发也就容易多了。其实这也就是常识性的东西，只是现在不少人浮躁的连常识都没有了。]]></description>
			<content:encoded><![CDATA[<p>国内搞游戏开发的常用脚本语言大致两种（Python与Lua），其中刚入行的游戏开发者都会有类似的问题：Lua该怎么用？谁为主谁为辅？C++与Lua该如何交互？</p>
<p>最近浏览stackoverflow发现这几个不错的帖子，分享给大家：</p>
<p><a title="http://stackoverflow.com/questions/2674462/lua-and-c-separation-of-duties" href="http://stackoverflow.com/questions/2674462/lua-and-c-separation-of-duties">http://stackoverflow.com/questions/2674462/lua-and-c-separation-of-duties</a></p>
<p>Lua与C的责任分配问题。</p>
<p><a title="http://stackoverflow.com/questions/2685636/lua-game-state-and-game-loop" href="http://stackoverflow.com/questions/2685636/lua-game-state-and-game-loop">http://stackoverflow.com/questions/2685636/lua-game-state-and-game-loop</a></p>
<p>游戏大循环（game loop）该如何维护？</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p>另外国内网易云风的博客上也零零散散有些内容，可以参考。</p>
<p>我不是游戏开发业者，所以也不好发表什么建议。但是我想比较重要的一点，也是在程序设计理念上一直强调的一点是：你要知道你要做什么，你想完成什么功能需求。</p>
<p>有些人话都说不清楚，就想搞游戏设计开发。脑子里都是浆糊，怎么可能设计出清晰的程序逻辑。找一支笔一个本子，先把你的需求想法列出来，画个交互关系图，把时序逻辑理清了，该如何设计如何开发也就容易多了。其实这也就是常识性的东西，只是现在不少人浮躁的连常识都没有了。</p>
]]></content:encoded>
			<wfw:commentRss>http://sunxiunan.com/?feed=rss2&amp;p=1614</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>谈新技术学习方法-如何学习一门新技术新编程语言</title>
		<link>http://sunxiunan.com/?p=1597</link>
		<comments>http://sunxiunan.com/?p=1597#comments</comments>
		<pubDate>Sat, 03 Apr 2010 12:30:52 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[lua]]></category>
		<category><![CDATA[lua howto]]></category>

		<guid isPermaLink="false">http://sunxiunan.com/?p=1597</guid>
		<description><![CDATA[学习一门编程语言或者编程技术的方式基本上是这样一个流程： 1，对学习这门语言或者技术的必要性进行评估。比如你是工作需要，或者兴趣所至，甚至是为了把妹。这个必要性关系到你要学多深入，需要学习多长时间。 比如我想学Lua，是想学它如何在万把行代码里面实现了一个如此精巧的编程语言，想学习它的GC机制，学习它如何设计VM，如何用纯C语言设计项目等等。 2，寻找相关资源。比较好的起始点是这门技术的官方网站以及维基百科。 比如Lua语言的官方网站是http://www.lua.org，维基百科地址为http://en.wikipedia.org/wiki/Lua_%28programming_language%29 一般在google.com里面敲入&#34;lua wiki&#34;之类就能直接搜索到相关维基条目。使用维基百科的好处是能够对编程语言有个概括了解，基本上看了以后，你都可以跟别人扯上几句一点问题也没有。另外维基百科在编程语言相关条目中有一个很有意思的特色就是：influenced by以及influenced列表。比如Lua条目中注明被Scheme、SNOBOL、Modula、CLU、C++所影响，影响了IO、GameMonkey、Squirrel、Falcon、Dao、MiniD这些语言，通过它可以了解到这门语言的祖先以及后代，相当的有意思。 而在官方网站，会有最新鲜的新闻、下载、文档帮助、论坛等相关内容。 3 找到官网以后，就要花上一段时间在官方网站好好浏览探寻一番。比如Lua官方网站的about栏目介绍了Lua是什么，为什么选择Lua，谁编写了Lua代码等等。在News栏目有关于Lua的最新新闻。Download栏目中有软件下载，学习一门语言，重要的是在练习中学习，大多数人都用Windows，就可以遵照下载栏目的推荐下载Lua for windows。 4 下载了软件（Lua for windows），安装成功以后，就可以看看文档document了。在Lua的文档网页中有在线参考手册（reference manual），大多数编程语言也都会在下载安装包中自带一份手册文档（就我所知Ruby Python都是如此）。 如何系统的学习一门语言？通过手册不是什么好办法，手册内容相对教条枯燥，读起来不容易。而且在线学习注意力不容易集中，很容易点着点着就跑偏了。最好的办法还是要买一本实体的参考书。 买实体书就要用到amazon或者douban了，你可以根据amazon以及douban上的打分来确定这本书的好坏，另外在Lua的document页面也有几本书推荐，像是Lua这种略微偏门的语言，其实选书很简单，因为就那么两三本，我个人推荐Programming in lua，国内有翻译版本，另外也可以下载到5.0的中文版。 那么对于java、dotnet这类参考书乌央乌央的技术来说，该如何选书？这时候我会参考以下几个因素：一个是语言创始人写的可选择，一个是奥莱里oreilly出版的可以买，另外可以参考豆瓣或者amazon的书单功能，看看其他人都推荐什么。最不济的办法可以看销量，销量高的书未必就好，但是选了也不至于错的离谱。 买到书以后，最好花上几天时间通读一下，对于不理解的部分先标记略过，力争先对语言技术的整体有个了解，对于一些基本操作、命令有一些印象。 5 通读以后就要细读了，一般来讲，每个编程语言都力争相对完整，所以必然有一些你未必感兴趣的内容或者用不到的内容，这些都可以放在一边需要时候再捡起来。细读的过程最好准备个小本子，另外建议在github上注册一个账号，github有个gist.github.com页面可以保存代码片段，在做代码练习的时候很有用。 细读的过程力争完全理解，书上的示例代码也都尽量自己敲进去运行一次，另外可以对示例代码做一定的扩展，比如在第五章的代码中加入第四章的代码，让它们组合起来看看如何。 6 用一两个月时间细读以后就是熟练提高阶段。当你细读了感兴趣的章节，最好在一段时间内尽量用新语言完成自己的编程需求，比如写个网络爬虫，或者删除某个目录下的特定文件，或者做做文本处理，一定要经常用才不会忘记。这段使用过程可能需要两三个月的时间，力争达到常见的代码函数不怎么查手册就可以熟练写下来。另外可以有意的对自己已经完成的算法或者应用进行语言上的翻译，用新语言实现一下快速排序，实现一下正则表达式。编程其实就是个熟练过程，越练越顺手。 这个时候可以试着购买一些advanced级别的书籍，了解一些更深入的内容，书籍的好坏依然是到amazon或者douban上搜索。 提高的过程中可以订阅一些相关的博客内容，可以到blogsearch.google.com查找博客文章，或者到csdn、javaeye、cnblogs这样的技术相关博客站点搜索。看到好的文章，可以使用delicious.com这个书签网站保存起来以后慢慢阅读。 7 在这段期间包括以后的使用过程，如果出现问题怎么办？可以遵照以下顺序查找帮助： &#160;&#160;&#160; a）书籍或者手册，在线文档，在线帮助等等 &#160;&#160;&#160; b）在官网的wiki或者stackoverflow.com上搜索相关的关键字。 &#160;&#160;&#160; c）使用google搜索相关关键字。 &#160;&#160;&#160; d）到stackoverflow或者官方邮件列表、官方论坛中提问。 一般来说最好订阅这门语言的邮件列表，比如Lua的邮件列表就是http://www.lua.org/lua-l.html 即使不提问，看看别人的问题也是很有意思的。 我不建议大家加入什么QQ群学习，QQ或者msn的即时通讯特性决定了它不是一个很好的学习方式，基本上只适合打屁聊天。 8 到了四五个月以后，按照前面步骤学下来的朋友应该已经算是中级水平了，不太可能问出什么“跪求、裸求”之类的弱智问题。这时候就可以往更深入的层次发展，比如试着读读源代码，试着写写相关编程库编程插件，在官方论坛、maillist、stackoverflow里面多帮人解答解答问题，试着多写写自己对于这门语言的使用经验，分享一些相关问题等等，就此走向“破碎虚空”的高手之路。 好了，就这样吧！]]></description>
			<content:encoded><![CDATA[<p>学习一门编程语言或者编程技术的方式基本上是这样一个流程：</p>
<p>1，对学习这门语言或者技术的必要性进行评估。比如你是工作需要，或者兴趣所至，甚至是为了把妹。这个必要性关系到你要学多深入，需要学习多长时间。</p>
<p>比如我想学Lua，是想学它如何在万把行代码里面实现了一个如此精巧的编程语言，想学习它的GC机制，学习它如何设计VM，如何用纯C语言设计项目等等。</p>
<p>2，寻找相关资源。比较好的起始点是这门技术的官方网站以及维基百科。</p>
<p>比如Lua语言的官方网站是<a href="http://www.lua.org">http://www.lua.org</a>，维基百科地址为<a title="http://en.wikipedia.org/wiki/Lua_%28programming_language%29" href="http://en.wikipedia.org/wiki/Lua_%28programming_language%29">http://en.wikipedia.org/wiki/Lua_%28programming_language%29</a></p>
<p>一般在google.com里面敲入&quot;lua wiki&quot;之类就能直接搜索到相关维基条目。使用维基百科的好处是能够对编程语言有个概括了解，基本上看了以后，你都可以跟别人扯上几句一点问题也没有。另外维基百科在编程语言相关条目中有一个很有意思的特色就是：influenced by以及influenced列表。比如Lua条目中注明被Scheme、SNOBOL、Modula、CLU、C++所影响，影响了IO、GameMonkey、Squirrel、Falcon、Dao、MiniD这些语言，通过它可以了解到这门语言的祖先以及后代，相当的有意思。</p>
<p>而在官方网站，会有最新鲜的新闻、下载、文档帮助、论坛等相关内容。</p>
<p><a href="http://sunxiunan.com/wp-content/uploads/2010/04/image.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://sunxiunan.com/wp-content/uploads/2010/04/image_thumb.png" width="467" height="427" /></a> </p>
<p>3 找到官网以后，就要花上一段时间在官方网站好好浏览探寻一番。比如Lua官方网站的about栏目介绍了Lua是什么，为什么选择Lua，谁编写了Lua代码等等。在News栏目有关于Lua的最新新闻。Download栏目中有软件下载，学习一门语言，重要的是在练习中学习，大多数人都用Windows，就可以遵照下载栏目的推荐下载Lua for windows。</p>
<p>4 下载了软件（Lua for windows），安装成功以后，就可以看看文档document了。在Lua的文档网页中有在线参考手册（reference manual），大多数编程语言也都会在下载安装包中自带一份手册文档（就我所知Ruby Python都是如此）。</p>
<p>如何系统的学习一门语言？通过手册不是什么好办法，手册内容相对教条枯燥，读起来不容易。而且在线学习注意力不容易集中，很容易点着点着就跑偏了。最好的办法还是要买一本实体的参考书。</p>
<p>买实体书就要用到amazon或者douban了，你可以根据amazon以及douban上的打分来确定这本书的好坏，另外在Lua的document页面也有几本书推荐，像是Lua这种略微偏门的语言，其实选书很简单，因为就那么两三本，我个人推荐Programming in lua，国内有翻译版本，另外也可以下载到5.0的中文版。</p>
<p><a href="http://sunxiunan.com/wp-content/uploads/2010/04/image1.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://sunxiunan.com/wp-content/uploads/2010/04/image_thumb1.png" width="83" height="105" /></a> <a href="http://sunxiunan.com/wp-content/uploads/2010/04/image2.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://sunxiunan.com/wp-content/uploads/2010/04/image_thumb2.png" width="77" height="100" /></a> </p>
<p>那么对于java、dotnet这类参考书乌央乌央的技术来说，该如何选书？这时候我会参考以下几个因素：一个是语言创始人写的可选择，一个是奥莱里oreilly出版的可以买，另外可以参考豆瓣或者amazon的书单功能，看看其他人都推荐什么。最不济的办法可以看销量，销量高的书未必就好，但是选了也不至于错的离谱。</p>
<p>买到书以后，最好花上几天时间通读一下，对于不理解的部分先标记略过，力争先对语言技术的整体有个了解，对于一些基本操作、命令有一些印象。</p>
<p>5 通读以后就要细读了，一般来讲，每个编程语言都力争相对完整，所以必然有一些你未必感兴趣的内容或者用不到的内容，这些都可以放在一边需要时候再捡起来。细读的过程最好准备个小本子，另外建议在github上注册一个账号，github有个gist.github.com页面可以保存代码片段，在做代码练习的时候很有用。</p>
<p>细读的过程力争完全理解，书上的示例代码也都尽量自己敲进去运行一次，另外可以对示例代码做一定的扩展，比如在第五章的代码中加入第四章的代码，让它们组合起来看看如何。</p>
<p>6 用一两个月时间细读以后就是熟练提高阶段。当你细读了感兴趣的章节，最好在一段时间内尽量用新语言完成自己的编程需求，比如写个网络爬虫，或者删除某个目录下的特定文件，或者做做文本处理，一定要经常用才不会忘记。这段使用过程可能需要两三个月的时间，力争达到常见的代码函数不怎么查手册就可以熟练写下来。另外可以有意的对自己已经完成的算法或者应用进行语言上的翻译，用新语言实现一下快速排序，实现一下正则表达式。编程其实就是个熟练过程，越练越顺手。</p>
<p>这个时候可以试着购买一些advanced级别的书籍，了解一些更深入的内容，书籍的好坏依然是到amazon或者douban上搜索。</p>
<p>提高的过程中可以订阅一些相关的博客内容，可以到blogsearch.google.com查找博客文章，或者到csdn、javaeye、cnblogs这样的技术相关博客站点搜索。看到好的文章，可以使用delicious.com这个书签网站保存起来以后慢慢阅读。</p>
<p>7 在这段期间包括以后的使用过程，如果出现问题怎么办？可以遵照以下顺序查找帮助：</p>
<p>&#160;&#160;&#160; a）书籍或者手册，在线文档，在线帮助等等</p>
<p>&#160;&#160;&#160; b）在官网的wiki或者stackoverflow.com上搜索相关的关键字。</p>
<p>&#160;&#160;&#160; c）使用google搜索相关关键字。</p>
<p>&#160;&#160;&#160; d）到stackoverflow或者官方邮件列表、官方论坛中提问。</p>
<p>一般来说最好订阅这门语言的邮件列表，比如Lua的邮件列表就是<a title="http://www.lua.org/lua-l.html" href="http://www.lua.org/lua-l.html">http://www.lua.org/lua-l.html</a> 即使不提问，看看别人的问题也是很有意思的。</p>
<p>我不建议大家加入什么QQ群学习，QQ或者msn的即时通讯特性决定了它不是一个很好的学习方式，基本上只适合打屁聊天。</p>
<p>8 到了四五个月以后，按照前面步骤学下来的朋友应该已经算是中级水平了，不太可能问出什么“跪求、裸求”之类的弱智问题。这时候就可以往更深入的层次发展，比如试着读读源代码，试着写写相关编程库编程插件，在官方论坛、maillist、stackoverflow里面多帮人解答解答问题，试着多写写自己对于这门语言的使用经验，分享一些相关问题等等，就此走向“破碎虚空”的高手之路。</p>
<p>好了，就这样吧！</p>
]]></content:encoded>
			<wfw:commentRss>http://sunxiunan.com/?feed=rss2&amp;p=1597</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>[Translate] 七天学习七门编程语言IOLanguage第一天</title>
		<link>http://sunxiunan.com/?p=1588</link>
		<comments>http://sunxiunan.com/?p=1588#comments</comments>
		<pubDate>Mon, 29 Mar 2010 05:51:20 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[lua]]></category>
		<category><![CDATA[IOLanguage]]></category>

		<guid isPermaLink="false">http://sunxiunan.com/?p=1588</guid>
		<description><![CDATA[http://oscardelben.com/seven-languages-io-day-1 我刚买了Seven languages in seven weeks这本书的Beta版，真是一本好书。 这本书每章介绍一门编程语言，总共是七门语言。每章你都能找到语言的介绍，还有一些练习和自学题目。实际上每章也分成三天，我将用“第一天”“第二天”“第三天”来写它们。 这本书里介绍了下面这些编程语言： Ruby IOLanguage Prolog Scala Erlang Clujure Haskell 因为我（原作者）知道ruby了，就很快翻到第二章IOLanguage。IO是一门原型编程语言，某种程度上类似javascript（译者注：类似语言还有Lua）。我喜欢这门语言的语法和简洁性。 在Mac os X上安装IO 如果你想编译所有依赖库，从源代码开始安装需要一些时间。这里我们使用macports来获取所有依赖库，你可以在这里http://www.iolanguage.com/scm/io/docs/IoGuide.html#Introduction-Installing找到详细的安装文档。 1: cd ~/ 2: git clone git://github.com/stevedekorte/io.git 3: cd io 4: make vm; sudo make install; sudo make port; sudo make install 你可能不得不加入一些辅助库，可以参考前面关于安装的在线文档知道详细步骤。 如果你想安装textmate的绑定，可以运行以下命令： 1: cd &#34;/Library/Application Support/TextMate/Bundles&#34; 2: svn co http://svn.textmate.org/trunk/Bundles/Io.tmbundle/ 就是这些，现在可以运行Terminal程序了。 IO语言基础 IO编程语言的完整介绍可以参考这里http://www.iolanguage.com/scm/io/docs/IoGuide.html [...]]]></description>
			<content:encoded><![CDATA[<p><a title="http://oscardelben.com/seven-languages-io-day-1" href="http://oscardelben.com/seven-languages-io-day-1">http://oscardelben.com/seven-languages-io-day-1</a></p>
<p>我刚买了<a href="http://www.pragprog.com/titles/btlang/seven-languages-in-seven-weeks">Seven languages in seven weeks</a>这本书的Beta版，真是一本好书。</p>
<p> <span id="more-1588"></span>
<p>这本书每章介绍一门编程语言，总共是七门语言。每章你都能找到语言的介绍，还有一些练习和自学题目。实际上每章也分成三天，我将用“第一天”“第二天”“第三天”来写它们。</p>
<p>这本书里介绍了下面这些编程语言：</p>
<p>Ruby</p>
<p>IOLanguage</p>
<p>Prolog</p>
<p>Scala</p>
<p>Erlang</p>
<p>Clujure</p>
<p>Haskell</p>
<p>因为我（原作者）知道ruby了，就很快翻到第二章IOLanguage。IO是一门原型编程语言，某种程度上类似javascript（译者注：类似语言还有Lua）。我喜欢这门语言的语法和简洁性。</p>
<p><font size="4">在Mac os X上安装IO</font></p>
<p>如果你想编译所有依赖库，从源代码开始安装需要一些时间。这里我们使用macports来获取所有依赖库，你可以在这里<a title="http://www.iolanguage.com/scm/io/docs/IoGuide.html#Introduction-Installing" href="http://www.iolanguage.com/scm/io/docs/IoGuide.html#Introduction-Installing">http://www.iolanguage.com/scm/io/docs/IoGuide.html#Introduction-Installing</a>找到详细的安装文档。</p>
<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
<div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1"> 1:</span> cd ~/</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum2"> 2:</span> git clone git:<span style="color: #008000">//github.com/stevedekorte/io.git</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum3"> 3:</span> cd io</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum4"> 4:</span> make vm; sudo make install; sudo make port; sudo make install</pre>
<p><!--CRLF--></div>
</div>
<p>你可能不得不加入一些辅助库，可以参考前面关于安装的在线文档知道详细步骤。</p>
<p>如果你想安装textmate的绑定，可以运行以下命令：</p>
<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
<div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1"> 1:</span> cd <span style="color: #006080">&quot;/Library/Application Support/TextMate/Bundles&quot;</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum2"> 2:</span> svn co http://svn.textmate.org/trunk/Bundles/Io.tmbundle/</pre>
<p><!--CRLF--></div>
</div>
<p>就是这些，现在可以运行Terminal程序了。</p>
<p><font size="4">IO语言基础</font></p>
<p>IO编程语言的完整介绍可以参考这里<a title="http://www.iolanguage.com/scm/io/docs/IoGuide.html" href="http://www.iolanguage.com/scm/io/docs/IoGuide.html">http://www.iolanguage.com/scm/io/docs/IoGuide.html</a></p>
<p>下面是一个简单的预览：</p>
<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
<div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1"> 1:</span> Io 20090105</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum2"> 2:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum3"> 3:</span> Io&gt; 3 * 4</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum4"> 4:</span> ==&gt; 12</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum5"> 5:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum6"> 6:</span> Io&gt; Animal := Object clone</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum7"> 7:</span> ==&gt; Animal_0x10034c170:</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum8"> 8:</span> type = <span style="color: #006080">&quot;Animal&quot;</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum9"> 9:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum10"> 10:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum11"> 11:</span> Io&gt; Animal description := <span style="color: #006080">&quot;All animals in the world&quot;</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum12"> 12:</span> ==&gt; All animals <span style="color: #0000ff">in</span> the world</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum13"> 13:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum14"> 14:</span> Io&gt; dog := Animal clone</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum15"> 15:</span> ==&gt; Animal_0x10033f5f0:</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum16"> 16:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum17"> 17:</span> Io&gt; dog description</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum18"> 18:</span> ==&gt; All animals <span style="color: #0000ff">in</span> the world</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum19"> 19:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum20"> 20:</span> Io&gt; dog description := <span style="color: #006080">&quot;A generic dog&quot;</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum21"> 21:</span> ==&gt; A generic dog</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum22"> 22:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum23"> 23:</span> Io&gt; dog description</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum24"> 24:</span> ==&gt; A generic dog</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum25"> 25:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum26"> 26:</span> Io&gt; dog talk := method(<span style="color: #006080">&quot;Baw&quot;</span> print)</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum27"> 27:</span> ==&gt; method(</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum28"> 28:</span> <span style="color: #006080">&quot;Baw&quot;</span> print</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum29"> 29:</span> )</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum30"> 30:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum31"> 31:</span> Io&gt; dog talk()</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum32"> 32:</span> Baw==&gt; Baw</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum33"> 33:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum34"> 34:</span> Io&gt; list(1, 2, 3) sum</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum35"> 35:</span> ==&gt; 6</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum36"> 36:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum37"> 37:</span> Io&gt; list(1, 2, 3) average</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum38"> 38:</span> ==&gt; 2</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum39"> 39:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum40"> 40:</span> Io&gt; list(1, 2, 3) map(x, x * x)</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum41"> 41:</span> ==&gt; list(1, 4, 9)</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum42"> 42:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum43"> 43:</span> Io&gt; fibonacci := method(n, <span style="color: #0000ff">if</span>(n &lt; 2, n, (fibonacci(n -1) + fibonacci(n - 2))))</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum44"> 44:</span> ==&gt; method(n,</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum45"> 45:</span> <span style="color: #0000ff">if</span>(n &lt; 2, n, (fibonacci(n - 1) + fibonacci(n - 2)))</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum46"> 46:</span> )</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum47"> 47:</span> Io&gt; fibonacci(34)</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum48"> 48:</span> ==&gt; 5702887</pre>
<p><!--CRLF--></div>
</div>
<p>先别担心这语言看上去有些怪异，实际上你会发现它的语法非常简单。</p>
<p><font size="4">通过IO建立一个在线新闻程序</font></p>
<p>这是我做的一个小练习，刚刚学过语言以后，用IO语言在20分钟内创建一个简单版本的新闻平台。代码不是很出彩，但是它证明了使用IO多轻松简单。</p>
<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
<div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1"> 1:</span> # INSTANTIATE DB</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum2"> 2:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum3"> 3:</span> db := SQLite clone</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum4"> 4:</span> db setPath(<span style="color: #006080">&quot;news.sqlite&quot;</span>)</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum5"> 5:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum6"> 6:</span> # HTML HELPERS</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum7"> 7:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum8"> 8:</span> ul := method(content, <span style="color: #006080">&quot;&lt;ul&gt;&quot;</span> .. content .. <span style="color: #006080">&quot;&lt;/ul&gt;&quot;</span>)</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum9"> 9:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum10"> 10:</span> li := method(content, <span style="color: #006080">&quot;&lt;li&gt;&quot;</span>.. content .. <span style="color: #006080">&quot;&lt;/li&gt;&quot;</span>)</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum11"> 11:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum12"> 12:</span> a := method(text, url, <span style="color: #006080">&quot;&lt;a href=\&quot;#{url}\&quot;&gt;#{text}&lt;/a&gt;&quot;</span> interpolate)</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum13"> 13:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum14"> 14:</span> form := method(action, content, <span style="color: #006080">&quot;&lt;form action=\&quot;#{action}\&quot; method=\&quot;get\&quot;&gt;&quot;</span> interpolate .. content .. <span style="color: #006080">&quot;&lt;/form&gt;&quot;</span>)</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum15"> 15:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum16"> 16:</span> field := method(name, <span style="color: #006080">&quot;&lt;label&gt;#{name}&lt;/label&gt;: &lt;input type=\&quot;text\&quot; name=\&quot;#{name}\&quot; \&gt;&quot;</span> interpolate)</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum17"> 17:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum18"> 18:</span> submit := method(<span style="color: #006080">&quot;&lt;input type=\&quot;submit\&quot; /&gt;&quot;</span>)</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum19"> 19:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum20"> 20:</span> with_template := method(title, body,</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum21"> 21:</span> <span style="color: #006080">&quot;&lt;!DOCTYPE HTML PUBLIC \&quot;-//W3C//DTD HTML 4.01 Transitional//EN\&quot;</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum22"> 22:</span> \&quot;http://www.w3.org/TR/html4/loose.dtd\&quot;&gt;</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum23"> 23:</span> &lt;html&gt;</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum24"> 24:</span> &lt;head&gt;</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum25"> 25:</span> &lt;meta http-equiv=\&quot;Content-type\&quot; content=\&quot;text/html; charset=utf-8\&quot;&gt;</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum26"> 26:</span> &lt;title&gt;&quot;</span> .. title .. <span style="color: #006080">&quot;&lt;/title&gt;</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum27"> 27:</span> &lt;style type=\&quot;text/css\&quot; media=\&quot;screen\&quot;&gt;</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum28"> 28:</span> body {</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum29"> 29:</span> background:#ffffcc;</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum30"> 30:</span> margin:20px;</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum31"> 31:</span> padding:0;</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum32"> 32:</span> font-family:Calibri;</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum33"> 33:</span> font-size:18px;</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum34"> 34:</span> }</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum35"> 35:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum36"> 36:</span> h1 {</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum37"> 37:</span> color:#006363;</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum38"> 38:</span> margin:1em;</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum39"> 39:</span> }</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum40"> 40:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum41"> 41:</span> a {</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum42"> 42:</span> color:#ff7373;</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum43"> 43:</span> font-size:20px;</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum44"> 44:</span> }</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum45"> 45:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum46"> 46:</span> li {</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum47"> 47:</span> line-height:1.5em;</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum48"> 48:</span> }</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum49"> 49:</span> &lt;/style&gt;</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum50"> 50:</span> &lt;/head&gt;</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum51"> 51:</span> &lt;body&gt;&quot;</span> .. a(<span style="color: #006080">&quot;Home&quot;</span>, <span style="color: #006080">&quot;/&quot;</span>) .. <span style="color: #006080">&quot; - &quot;</span> .. a(<span style="color: #006080">&quot;New&quot;</span>, <span style="color: #006080">&quot;/new&quot;</span>) .. <span style="color: #006080">&quot;&lt;h1&gt;&quot;</span> .. title .. <span style="color: #006080">&quot;&lt;/h1&gt;&quot;</span> .. body .. <span style="color: #006080">&quot;&lt;/body&gt;&lt;/html&gt;&quot;</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum52"> 52:</span> )</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum53"> 53:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum54"> 54:</span> # Actions</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum55"> 55:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum56"> 56:</span> render_index := method(<span style="color: #0000ff">params</span>,</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum57"> 57:</span> db open</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum58"> 58:</span> posts := db exec(<span style="color: #006080">&quot;SELECT * from posts&quot;</span>)</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum59"> 59:</span> db close</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum60"> 60:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum61"> 61:</span> posts_html := posts map(post, li( a( post at(<span style="color: #006080">&quot;title&quot;</span>), post at(<span style="color: #006080">&quot;url&quot;</span>) ) ) ) join</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum62"> 62:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum63"> 63:</span> with_template(<span style="color: #006080">&quot;Io News&quot;</span>, ul(posts_html))</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum64"> 64:</span> )</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum65"> 65:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum66"> 66:</span> render_new := method(<span style="color: #0000ff">params</span>,</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum67"> 67:</span> with_template(<span style="color: #006080">&quot;New&quot;</span>, form(<span style="color: #006080">&quot;/create&quot;</span>, field(<span style="color: #006080">&quot;title&quot;</span>) .. field(<span style="color: #006080">&quot;url&quot;</span>) .. submit() ))</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum68"> 68:</span> )</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum69"> 69:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum70"> 70:</span> render_create := method(<span style="color: #0000ff">params</span>,</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum71"> 71:</span> db open</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum72"> 72:</span> db exec(<span style="color: #006080">&quot;INSERT into posts (title, url)</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum73"> 73:</span> values ('#{params at(\&quot;title\&quot;)}', '#{params at(\&quot;url\&quot;)}')&quot;</span> interpolate)</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum74"> 74:</span> db close</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum75"> 75:</span> with_template(<span style="color: #006080">&quot;Hurray!&quot;</span>, <span style="color: #006080">&quot;Io rocks!&quot;</span>)</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum76"> 76:</span> )</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum77"> 77:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum78"> 78:</span> not_found := method(</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum79"> 79:</span> with_template(<span style="color: #006080">&quot;Not found&quot;</span>)</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum80"> 80:</span> )</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum81"> 81:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum82"> 82:</span> # Unfortunately I had to manually extract the parameters</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum83"> 83:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum84"> 84:</span> extract_parameters := method(<span style="color: #0000ff">string</span>,</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum85"> 85:</span> # foo=bar&amp;x=y =&gt; list(list(<span style="color: #006080">&quot;foo&quot;</span>, <span style="color: #006080">&quot;bar&quot;</span>), list(<span style="color: #006080">&quot;x&quot;</span>, <span style="color: #006080">&quot;y&quot;</span>))</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum86"> 86:</span> l := <span style="color: #0000ff">string</span> split(<span style="color: #006080">&quot;&amp;&quot;</span>) map(param, param split(<span style="color: #006080">&quot;=&quot;</span>))</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum87"> 87:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum88"> 88:</span> <span style="color: #0000ff">params</span> := Map clone</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum89"> 89:</span> l <span style="color: #0000ff">foreach</span>(param, <span style="color: #0000ff">params</span> atPut(param at(0), param at(1)))</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum90"> 90:</span> <span style="color: #0000ff">params</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum91"> 91:</span> )</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum92"> 92:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum93"> 93:</span> handle_request := method(request,</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum94"> 94:</span> path_and_parameters := request split(<span style="color: #006080">&quot;?&quot;</span>)</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum95"> 95:</span> path := path_and_parameters at(0)</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum96"> 96:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum97"> 97:</span> <span style="color: #0000ff">if</span>(path_and_parameters size &gt; 1,</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum98"> 98:</span> parameters := extract_parameters(path_and_parameters at(1)),</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum99"> 99:</span> parameters := nil</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum100"> 100:</span> )</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum101"> 101:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum102"> 102:</span> # Does anyone know how to implement cond()?</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum103"> 103:</span> <span style="color: #0000ff">if</span>(path == <span style="color: #006080">&quot;/&quot;</span>,</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum104"> 104:</span> render_index(parameters),</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum105"> 105:</span> <span style="color: #0000ff">if</span>(path == <span style="color: #006080">&quot;/new&quot;</span>,</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum106"> 106:</span> render_new(parameters),</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum107"> 107:</span> <span style="color: #0000ff">if</span>(path == <span style="color: #006080">&quot;/create&quot;</span>,</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum108"> 108:</span> render_create(parameters),</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum109"> 109:</span> not_found</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum110"> 110:</span> )</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum111"> 111:</span> )</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum112"> 112:</span> )</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum113"> 113:</span> )</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum114"> 114:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum115"> 115:</span> WebRequest := Object clone <span style="color: #0000ff">do</span>(</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum116"> 116:</span> handleSocket := method(aSocket,</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum117"> 117:</span> aSocket streamReadNextChunk</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum118"> 118:</span> request := aSocket readBuffer betweenSeq(<span style="color: #006080">&quot;GET &quot;</span>, <span style="color: #006080">&quot; HTTP&quot;</span>)</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum119"> 119:</span> aSocket streamWrite(handle_request(request))</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum120"> 120:</span> aSocket close</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum121"> 121:</span> )</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum122"> 122:</span> )</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum123"> 123:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum124"> 124:</span> WebServer := Server clone <span style="color: #0000ff">do</span>(</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum125"> 125:</span> setPort(8000)</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum126"> 126:</span> handleSocket := method(aSocket,</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum127"> 127:</span> WebRequest clone @handleSocket(aSocket)</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum128"> 128:</span> )</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum129"> 129:</span> )</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum130"> 130:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum131"> 131:</span> WebServer start</pre>
<p><!--CRLF--></div>
</div>
<p>如果你想运行代码，你可能需要先建立一个数据库结构，下面是我的步骤：</p>
<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
<div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1"> 1:</span> db := SQLite clone</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum2"> 2:</span> db setPath(<span style="color: #006080">&quot;news.sqlite&quot;</span>)</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum3"> 3:</span> db open</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum4"> 4:</span> db exec(<span style="color: #006080">&quot;CREATE TABLE posts(id INTEGER PRIMARY KEY ASC,</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum5"> 5:</span> title VARCHAR(255),</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum6"> 6:</span> url VARCHAR(255),</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum7"> 7:</span> published_at DATE)&quot;</span>)</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum8"> 8:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum9"> 9:</span> db exec(<span style="color: #006080">&quot;INSERT INTO posts (title, url, published_at)</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum10"> 10:</span> values</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum11"> 11:</span> ('Welcome aboard', 'http://example.com', DATETIME('NOW'))&quot;</span>)</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum12"> 12:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum13"> 13:</span> db exec(<span style="color: #006080">&quot;INSERT INTO posts (title, url, published_at)</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum14"> 14:</span> values</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum15"> 15:</span> ('Io documentation', 'http://www.iolanguage.com/scm/io/docs/IoGuide.html', DATETIME('NOW'))&quot;</span>)</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum16"> 16:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum17"> 17:</span> db close</pre>
<p><!--CRLF--></div>
</div>
<p> 结果如下：</p>
<p><a href="http://sunxiunan.com/media/Translate1IOLanguage_BDF5/image.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://sunxiunan.com/media/Translate1IOLanguage_BDF5/image_thumb.png" width="508" height="453" /></a> </p>
<p><a href="http://sunxiunan.com/media/Translate1IOLanguage_BDF5/image_3.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://sunxiunan.com/media/Translate1IOLanguage_BDF5/image_thumb_3.png" width="508" height="453" /></a> </p>
<p><a href="http://sunxiunan.com/media/Translate1IOLanguage_BDF5/image_4.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://sunxiunan.com/media/Translate1IOLanguage_BDF5/image_thumb_4.png" width="508" height="453" /></a> </p>
<p><a href="http://sunxiunan.com/media/Translate1IOLanguage_BDF5/image_5.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://sunxiunan.com/media/Translate1IOLanguage_BDF5/image_thumb_5.png" width="508" height="453" /></a> </p>
<p>个人而言，我非常喜欢IO语言，我可能会多学习它几天时间。</p>
]]></content:encoded>
			<wfw:commentRss>http://sunxiunan.com/?feed=rss2&amp;p=1588</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>使用Lua编写Utility的一些小贴士</title>
		<link>http://sunxiunan.com/?p=1576</link>
		<comments>http://sunxiunan.com/?p=1576#comments</comments>
		<pubDate>Mon, 08 Mar 2010 05:33:54 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[lua]]></category>

		<guid isPermaLink="false">http://sunxiunan.com/?p=1576</guid>
		<description><![CDATA[string trim功能 1: function string_trim(s) 2: if s == nil then 3: return 4: end 5:&#160; 6: return (string.gsub(s, &#34;^%s*(.-)%s*$&#34;, &#34;%1&#34;)) 7: end 检查某个字符串是不是指向合法目录。 1: function check_directory(s) 2: s = string_trim(s) 3: if not s or s == &#34;&#34; then 4: return false 5: end 6:&#160; 7: if string.sub(s, -1, -1) == [[\]]then 8: s [...]]]></description>
			<content:encoded><![CDATA[</p>
<p>string trim功能</p>
<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
<div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1"> 1:</span> function string_trim(s)</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum2"> 2:</span> <span style="color: #0000ff">if</span> s == nil then</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum3"> 3:</span> <span style="color: #0000ff">return</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum4"> 4:</span> end</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum5"> 5:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum6"> 6:</span> <span style="color: #0000ff">return</span> (<span style="color: #0000ff">string</span>.gsub(s, <span style="color: #006080">&quot;^%s*(.-)%s*$&quot;</span>, <span style="color: #006080">&quot;%1&quot;</span>))</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum7"> 7:</span> end</pre>
<p><!--CRLF--></div>
</div>
<p>检查某个字符串是不是指向合法目录。</p>
<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
<div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1"> 1:</span> function check_directory(s)</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum2"> 2:</span> s = string_trim(s)</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum3"> 3:</span> <span style="color: #0000ff">if</span> not s or s == <span style="color: #006080">&quot;&quot;</span> then</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum4"> 4:</span> <span style="color: #0000ff">return</span> <span style="color: #0000ff">false</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum5"> 5:</span> end</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum6"> 6:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum7"> 7:</span> <span style="color: #0000ff">if</span> <span style="color: #0000ff">string</span>.sub(s, -1, -1) == [[\]]then</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum8"> 8:</span> s = <span style="color: #0000ff">string</span>.sub(s, 1, -2)</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum9"> 9:</span> end</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum10"> 10:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum11"> 11:</span> local attr = lfs.attributes (s)</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum12"> 12:</span> <span style="color: #0000ff">if</span> (attr and attr.mode == <span style="color: #006080">&quot;directory&quot;</span>) then</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum13"> 13:</span> <span style="color: #0000ff">return</span> <span style="color: #0000ff">true</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum14"> 14:</span> end</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum15"> 15:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum16"> 16:</span> <span style="color: #0000ff">return</span> <span style="color: #0000ff">false</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum17"> 17:</span> end</pre>
<p><!--CRLF--></div>
</div>
<p>对于文件操作，最好先备份一下原来文件：</p>
<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
<div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1"> 1:</span> local str = <span style="color: #006080">&quot;copy \&quot;&quot;</span> .. Folder .. <span style="color: #006080">'\\log.db'</span> .. <span style="color: #006080">&quot;\&quot; \&quot;&quot;</span> .. Folder .. <span style="color: #006080">'\\log.db'</span> .. <span style="color: #006080">&quot;.&quot;</span> .. os.time() .. <span style="color: #006080">&quot;\&quot; /v /y&quot;</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum2"> 2:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum3"> 3:</span> os.execute(str)</pre>
<p><!--CRLF--></div>
</div>
<p>对于sqlite的操作，注意使用了一个自增myid作为key。</p>
<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
<div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1"> 1:</span> Db1 = sqlitelua.open(upFolder .. <span style="color: #006080">'\\mainlog.db'</span>)</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum2"> 2:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum3"> 3:</span> Db1:exec(<span style="color: #006080">'CREATE TABLE newfiles(myid INTEGER PRIMARY KEY AUTOINCREMENT, myname, myfolder)'</span>)</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum4"> 4:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum5"> 5:</span> local stmt1 = Db1:prepare[[ INSERT INTO newfiles VALUES (:myid, :myname, :myfolded) ]]</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum6"> 6:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum7"> 7:</span> stmt1:bind_names{myname = new_name, myfolder = currentFolder}</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum8"> 8:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum9"> 9:</span> stmt1:step()</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum10"> 10:</span> stmt1:reset()</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum11"> 11:</span> stmt1:finalize()</pre>
<p><!--CRLF--></div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://sunxiunan.com/?feed=rss2&amp;p=1576</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Lua程序设计（第二版）阅读笔记</title>
		<link>http://sunxiunan.com/?p=1542</link>
		<comments>http://sunxiunan.com/?p=1542#comments</comments>
		<pubDate>Wed, 24 Feb 2010 01:05:21 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[lua]]></category>

		<guid isPermaLink="false">http://sunxiunan.com/?p=1542</guid>
		<description><![CDATA[&#160; 很有意思的是，下面的代码是有效地，我也是看了书才知道。代码后面可以跟着，也可以不跟分号。 1: a = 5 b = 6 2: c = 7; d = 8; 3: print(a, b, c, d) Lua中，什么是字母依赖于locale的设置，也就是中文环境下，中文可以用作变量名（？这个需验证） Lua有大小写之分。 常用的块注释方式是&#8211;[[然后以--]]结尾，这样如果想取消块注释，就把开头多加个-就行了。 LUA_INIT内容为@文件名，解释器会先执行这个文件（？需验证）。 Lua中的（以后省略）函数为第一类值，比如print = type; print(a); 这个是合法合理的，但是print就没有了，一般用于沙箱sandbox操作。 条件判断只有两种情况为假，false以及nil。其余都为真。 number是实数（通常下）。用双精度代表整数，只要这个数字不大于10的14次方就没问题（本书这里笔误为1014，shit，我对照了PIL第一版确认的）。重新编译数字类型可以方便用于其它平台luaconf.h。数字可以写作4.57e-3 0.3e12 5e+20这种科学计数法。 Lua可以存储任意二进制字符到字符串类型中。5.1支持的长括号写法[===[匹配]===]，只要等号数量移植。字符串与数字运算，数字会转成字符串，可以用tonumber把字符变成数字。 1: local str = &#34;5e+20&#34; 2: local num = tonumber(str) 3: print(num) 数字转成字符，可以用tostring或者让数字与空字符串连接。 5.1的字符串支持#。 local a = {}创建了一个table，并且让a引用这个table，通过a这个变量我们可以操作这个table，如果没有变量继续引用这个table（a = nil），Lua会负责回收内存销毁它。 [...]]]></description>
			<content:encoded><![CDATA[<p>&#160;</p>
<p>很有意思的是，下面的代码是有效地，我也是看了书才知道。代码后面可以跟着，也可以不跟分号。</p>
<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
<div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1"> 1:</span> a = 5 b = 6</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum2"> 2:</span> c = 7; d = 8;</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum3"> 3:</span> print(a, b, c, d)</pre>
<p><!--CRLF--></div>
</div>
<p>Lua中，什么是字母依赖于locale的设置，也就是中文环境下，中文可以用作变量名（？这个需验证）</p>
<p>Lua有大小写之分。</p>
<p>常用的块注释方式是&#8211;[[然后以--]]结尾，这样如果想取消块注释，就把开头多加个-就行了。</p>
<p>LUA_INIT内容为@文件名，解释器会先执行这个文件（？需验证）。</p>
<p>Lua中的（以后省略）函数为第一类值，比如print = type; print(a); 这个是合法合理的，但是print就没有了，一般用于沙箱sandbox操作。</p>
<p>条件判断只有两种情况为假，false以及nil。其余都为真。</p>
<p>number是实数（通常下）。用双精度代表整数，只要这个数字不大于10的14次方就没问题（本书这里笔误为1014，shit，我对照了PIL第一版确认的）。重新编译数字类型可以方便用于其它平台luaconf.h。数字可以写作4.57e-3 0.3e12 5e+20这种科学计数法。</p>
<p>Lua可以存储任意二进制字符到字符串类型中。5.1支持的长括号写法[===[匹配]===]，只要等号数量移植。字符串与数字运算，数字会转成字符串，可以用tonumber把字符变成数字。</p>
<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
<div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1"> 1:</span> local str = <span style="color: #006080">&quot;5e+20&quot;</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum2"> 2:</span> local num = tonumber(str)</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum3"> 3:</span> print(num)</pre>
<p><!--CRLF--></div>
</div>
<p>数字转成字符，可以用tostring或者让数字与空字符串连接。</p>
<p>5.1的字符串支持#。</p>
<p>local a = {}创建了一个table，并且让a引用这个table，通过a这个变量我们可以操作这个table，如果没有变量继续引用这个table（a = nil），Lua会负责回收内存销毁它。</p>
<p>a[&quot;nameX“] = 5 等价于 a.nameX = 5，注意key里面的引号。local a = {}; a[x] = 5这个代码是不合法的。local a = {}; a[&quot;x&quot;] = 5; print(a.x);这个会打印出5。</p>
<p>长度操作#的常用做法，print(a[#a])打印最后一个（因为Lua的table索引从1开始），a[#a +1] = n常用与自增，a[#a] = nil删除最后一个。</p>
<p>注意当table中有空洞（数字索引不连续，或者某个值为nil）的时候，#操作未必得到正确值。</p>
<p>5.1新增%取模操作。a % b == a &#8211; floor(a / b) * b，结果符号永远与第二个参数相同。print(5 % -2)得到-1，print(-5 % 2)得到1。另外取模操作可以用于对实数取整数部分或者小数部分。x = math.pi; x &#8211; x % 0.01 是让x精确到小数点后2位。x % 1 取小数部分，x &#8211; x % 1 取到整数部分。</p>
<p>table，userdata以及function，比较引用。</p>
<p>and与or都是用短路求值。 x = x or v常用于默认值设置。</p>
<p>Lua中的字符串是不可变值immutable value，两个字符串链接，会返会一个新的字符串。</p>
<p>链表写法：</p>
<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
<div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1"> 1:</span> list = nil</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum2"> 2:</span> <span style="color: #0000ff">for</span> line <span style="color: #0000ff">in</span> io.lines() <span style="color: #0000ff">do</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum3"> 3:</span> list = {next = list, <span style="color: #0000ff">value</span> = line}</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum4"> 4:</span> end</pre>
<p><!--CRLF--></div>
</div>
<p>local a = { [-1] = 3, [&quot;3&quot;] = 5, [&quot;n&quot;] = &quot;bbb&quot;}; </p>
<p>print(a[-1]); print(a[&quot;3&quot;]); print(a.n);比较有意思的是a[&quot;3&quot;]没法写成a.3。</p>
<p>a = {x = 0, y = 0} 相当于a = {[&quot;x&quot;] = 0, [&quot;y&quot;] = 0}的语法特例。</p>
<p>local a = { [-1] = 3; [&quot;3&quot;] = 5; [&quot;n&quot;] = &quot;bbb&quot;};这样写也是合法的，构造式可以用分号代替逗号。</p>
<p>第四章</p>
<p>x, y = y, x交互x与y的值。</p>
<p>可以用do-end控制局部变量的范围。</p>
<p>local print = print，相当于定义了一个局部变量print（函数），后面如果使用print，就是访问了这个局部变量。访问局部变量要比访问全局变量快。</p>
<p>while x do .. end，当x为真值时进入while；repeat .. until x，当x为真值的时候结束循环。这点我弄混过。</p>
]]></content:encoded>
			<wfw:commentRss>http://sunxiunan.com/?feed=rss2&amp;p=1542</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Some interesting Lua code test</title>
		<link>http://sunxiunan.com/?p=1532</link>
		<comments>http://sunxiunan.com/?p=1532#comments</comments>
		<pubDate>Thu, 21 Jan 2010 06:11:17 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[lua]]></category>

		<guid isPermaLink="false">http://sunxiunan.com/?p=1532</guid>
		<description><![CDATA[When I read the book &#60;the ruby way&#62;, I get some interesting code that need to run in Lua. (I will test following code in Lua5.14 for windows package.) 1: print( 5 % 3) 2: print( -5 % 3) 3: print( 5 % -3) 4: print(-5 % -3) The result will be 2, 1, -1, [...]]]></description>
			<content:encoded><![CDATA[<p>When I read the book &lt;the ruby way&gt;, I get some interesting code that need to run in Lua. (I will test following code in Lua5.14 for windows package.)</p>
<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
<div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1"> 1:</span> print( 5 % 3)</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum2"> 2:</span> print( -5 % 3)</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum3"> 3:</span> print( 5 % -3)</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum4"> 4:</span> print(-5 % -3)</pre>
<p><!--CRLF--></div>
</div>
<p>The result will be 2, 1, -1, -2.</p>
<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
<div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1"> 1:</span> <span style="color: #0000ff">if</span> not nil then</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum2"> 2:</span> print(<span style="color: #006080">&quot;not nil&quot;</span>)</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum3"> 3:</span> end</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum4"> 4:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum5"> 5:</span> <span style="color: #0000ff">if</span> not <span style="color: #0000ff">false</span> then</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum6"> 6:</span> print(<span style="color: #006080">&quot;not false&quot;</span>)</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum7"> 7:</span> end</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum8"> 8:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum9"> 9:</span> <span style="color: #0000ff">if</span> 0 then</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum10"> 10:</span> print(<span style="color: #006080">&quot;0&quot;</span>)</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum11"> 11:</span> end</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum12"> 12:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum13"> 13:</span> <span style="color: #0000ff">if</span> <span style="color: #006080">&quot;&quot;</span> then</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum14"> 14:</span> print(<span style="color: #006080">&quot;empty string&quot;</span>)</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum15"> 15:</span> end</pre>
<p><!--CRLF--></div>
</div>
<p>The result will be &quot;not nil&quot;, &quot;not false&quot;, &quot;0&quot;, &quot;empty string&quot;, in Lua, only nil and false will be FALSE in condition checking.</p>
<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
<div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1"> 1:</span> <span style="color: #0000ff">for</span> i = 1, 5 <span style="color: #0000ff">do</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum2"> 2:</span> print(i)</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum3"> 3:</span> i = i + 5</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum4"> 4:</span> print(i)</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum5"> 5:</span> print(<span style="color: #006080">&quot;&quot;</span>)</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum6"> 6:</span> end</pre>
<p><!--CRLF--></div>
</div>
<p>OK, the result will be 1&#160; 6, 2&#160; 7, 3&#160; 8, 4&#160; 9, 5&#160; 10, you could see the index variable &quot;i&quot; is not changed for the for-loop, and you could assign new value (i=i+5) to it in the for range, but it will restore back to the loop index value again.</p>
<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
<div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1"> 1:</span> local x, y = {}</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum2"> 2:</span> print(x)</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum3"> 3:</span> print(y)</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum4"> 4:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum5"> 5:</span> y = x</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum6"> 6:</span> print(y)</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum7"> 7:</span> table.insert(y, <span style="color: #006080">&quot;aa&quot;</span>)</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum8"> 8:</span> print(x[1])</pre>
<p><!--CRLF--></div>
</div>
<p>It will print like &quot;table: 003CACB0&quot; &quot;nil&quot; &quot;table: 003CACB0&quot; &quot;aa&quot;.</p>
<p>Two thing need to note, local x, y = {} will only initialize the &quot;x&quot;. Another is the y will have same address with x if x is a table, and insert to table y will cause x changes too. It seems like in c or c++ only copy the pointer address, not copy the value with the pointer.</p>
]]></content:encoded>
			<wfw:commentRss>http://sunxiunan.com/?feed=rss2&amp;p=1532</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
