문제

Lua 5.2 (in contrast to 5.1) supports __gc for tables.

Has LuaJIT borrowed this nice feature?

(I did a google search, and examined LuaJIT's Change History but couldn't figure out the answer.)

도움이 되었습니까?

해결책

Just try it:

-- 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
$

So the short answer is no.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top