Code:
print(_VERSION) local a = setmetatable({}, {__mode = 'v'}) local b = setmetatable({}, {__gc = function(x) print("Deleting: " .. tostring(x)) end}) a[1] = b a[2] = 2 print(table.unpack(a)) print(collectgarbage'count') b = nil collectgarbage() print(table.unpack(a))
Lua 5.3 table: 0x50a748 2 21.4033203125 Deleting: table: 0x50a748 nil 2
Perhaps http://www.lua.org/demo.html could be replaced with that for users who have JS enabled.
Again - just wow, that's really nice, Lua in a browser.
Code:
Result: [0] - 3 features tied to the Lua GC, to simplify, they basically are (respectively): forcefully running the GC, finalizers that run when object is collected and weak refs that don't hold the object alive on their own.Perhaps http://www.lua.org/demo.html could be replaced with that for users who have JS enabled.
Again - just wow, that's really nice, Lua in a browser.