-
Recent Posts
Recent Comments
Archives
Categories
Meta
Category Archives: lua
how to detect garbage collection
> is there still any > equivalent way to have Lua run a particular function after each > garbage collection in the current version? You can try something like this: mt = {__gc = function () create_new_userdata_with_metatable(mt) end } create_new_userdata_with_metatable(mt) … Continue reading
Posted in lua
Leave a comment
weak tables and userdata caveat
If you want the gory details, there is another relevant stuff in the interaction between weak tables and userdata that is missing from the manual. Assume a userdata U that has a finalizer (a __gc metamethod). If U appears as … Continue reading
Posted in lua
Leave a comment
__gc for tables
from Lua FAQ : __gc for tables create a userdata; make the table the userdata’s environment table, and place a reference to the userdata in the table. (Make sure that this is the only reference to the userdata.) When the … Continue reading
Posted in lua
Leave a comment
words to set
Rici Lake to Lua I very fond of the following idiom: function wordsToSet(str, rv) rv = rv or {} for k in str:gmatch”%S+” do rv[k] = k end return rv end example = wordsToSet[[foo bar baz]]
Posted in lua
Leave a comment