![]() | 1 marvinII 2012-10-03 23:25:31 +08:00 是setmetatable 不是 meta data 5.1 manual 里有实现: function gettable_event (table, key) local h if type(table) == "table" then local v = rawget(table, key) if v ~= nil then return v end h = metatable(table).__index if h == nil then return nil end else h = metatable(table).__index if h == nil then error() end end if type(h) == "function" then return (h(table, key)) -- call the handler else return h[key] -- or repeat operation on it end end __index的作用就很清楚了。 Lua的问题都在mail list里讨论,可以订阅。另外,lua user wiki很好,很全面,可以参考。 |
![]() | 2 bugcoder 2012-10-04 09:05:35 +08:00 我感觉 LUA的兴起是从 暴雪公司的 魔兽世界开始的吧, 主要用来给该游戏开发插件.... |
![]() | 3 kran 2012-10-04 09:21:11 +08:00 pil一本书足够入门了,lua毕竟是特性比较少的语言。 index只是元表的其中一个特性,你迷惑可能是因为很多时候会直接把元表的index赋值为自身。 |
![]() | 4 jiyinyiyong OP @marvinII 没缩进给跪了.. 其实我写的还是 MoonScript 然后转的 Lua, 那个邮件列表能给链接么? |
![]() | 5 marvinII 2012-10-04 10:23:38 +08:00 @jiyinyiyong http://www.lua.org/lua-l.html @bugcoder 应用很广的, 包括Lego MindStorm NXT, Creative ZEN, SciTE (http://www.lua.org/uses.html), 只是国内的宣传方式决定了只有魔兽最显眼. 其实只要习惯/倾向于 mixed language programming 就到处都可以用了. |
![]() | 6 hpyhacking 2012-10-04 16:05:19 +08:00 国内比较小众的语言都是比较冷清的,Erlang也如此,就算是Ruby在国内的ruby-china上也不是很火爆,蛋逼的比讨论技术的多。 |
![]() | 7 weakfox 2012-10-04 16:24:38 +08:00 lua不是在游戏行业应用挺普遍的? |
![]() | 8 amtb 2013-02-05 18:24:07 +08:00 nginx+lua,性能神器,参考openresty |