lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


It was thus said that the Great Choonster TheMage once stated:
> On 28 Dec 2013 13:43, "Sean Conner" <sean@conman.org> wrote:
> >
> > Doing this for Lua 5.1 is not quite as easy, as you need to use a userdata
> > object (say, a pointer to int) instead of a Lua table, but the concept is
> > the same.
> >
> >   -spc
> >
> >
> 
> One possible solution for Lua 5.1 is to use the undocumented newproxy()
> function [1] to create your userdata object. I'm not at my computer at the
> moment so I can't be sure, but I think LuaJIT also supports it.

  The issue is that in Lua 5.1, you can't set the __gc() method on tables. 
Or, rather, you can, but it won't be called.  For the __gc() method to be
called, you need a userdata.

  -spc