LuaJIT是否支持表__gc?

Lua 5.2(与5.1相反)支持表的__gc.

LuaJIT是否借用了这个不错的功能?

(我做了谷歌搜索,并检查了LuaJIT的Change History,但无法找到答案.)

就试一试吧:

-- test.lua
do
  local x = setmetatable({},{
    __gc = function() print("works") end
  })
end
collectgarbage("collect")
collectgarbage("collect")

.

$lua51 -v
Lua 5.1.5  Copyright (C) 1994-2012 Lua.org, PUC-Rio
$lua51 test.lua
$lua52 -v
Lua 5.2.2  Copyright (C) 1994-2013 Lua.org, PUC-Rio
$lua52 test.lua
works
$luajit -v
LuaJIT 2.0.2 -- Copyright (C) 2005-2013 Mike Pall. http://luajit.org/
$luajit test.lua
$

所以简短的回答是否定的.

相关文章
相关标签/搜索