<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Lua on Laputa</title>
    <link>https://chenjianyong.com/zh/tags/lua/</link>
    <description>Recent content in Lua on Laputa</description>
    <generator>Hugo</generator>
    <language>zh-CN</language>
    <lastBuildDate>Sat, 29 Jan 2022 00:00:00 +0000</lastBuildDate>
    <atom:link href="https://chenjianyong.com/zh/tags/lua/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Lua: read-only table</title>
      <link>https://chenjianyong.com/zh/blog/2022/lua-read-only-table/</link>
      <pubDate>Sat, 29 Jan 2022 00:00:00 +0000</pubDate>
      <guid>https://chenjianyong.com/zh/blog/2022/lua-read-only-table/</guid>
      <description>&lt;h2 id=&#34;preface&#34;&gt;Preface&lt;/h2&gt;&#xA;&lt;p&gt;Lua 中的 API 都是以 Lua table 的方式存储并提供给用户使用，拿 OpenResty 中的 &lt;code&gt;ngx.say&lt;/code&gt; API 为例：其中 &lt;code&gt;ngx&lt;/code&gt; 是全局环境(也是一个 Lua table)中一个名为 &lt;code&gt;ngx&lt;/code&gt; 的 key 对应的 value(一个 table)，而 &lt;code&gt;say&lt;/code&gt;，则是 &lt;code&gt;ngx&lt;/code&gt; 这个 table 中一个名为 &lt;code&gt;say&lt;/code&gt; 的 key 对应的 value(一个 C function)；而 Lua 标准库也是如此。&lt;/p&gt;</description>
    </item>
    <item>
      <title>Lua: buffer system</title>
      <link>https://chenjianyong.com/zh/blog/2021/lua-buffer-system/</link>
      <pubDate>Sun, 14 Nov 2021 00:00:00 +0000</pubDate>
      <guid>https://chenjianyong.com/zh/blog/2021/lua-buffer-system/</guid>
      <description>&lt;h2 id=&#34;preface&#34;&gt;Preface&lt;/h2&gt;&#xA;&lt;p&gt;最近在实现一套和 OpenResty 中的 &lt;code&gt;ngx.re.*&lt;/code&gt; 类似的 API，其中 &lt;code&gt;gsub/sub&lt;/code&gt; 这俩用到了 &lt;code&gt;luaL_Buffer&lt;/code&gt;；在数据量比较小的情况下它工作的很好，可是一旦数据量上去了，程序就开始抛出异常，不过 OpenResty 却可以正常工作，着实困扰了我一阵；查阅资料发现网上说 &lt;code&gt;luaL_Buffer&lt;/code&gt; 的确比较坑，怀疑是不是我用的方式不太对；最终通过看内部实现发现了问题所在，写这篇 blog 记录下&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
