lua-users home
lua-l archive

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


On 4/13/06, Raymond Jacobs <raymondj@gmail.com> wrote:
> Greetings all,
>
>  in my test code:
>
>  while(1)
>  {
>          lua_pushstring(state,"woot!");
>          int ref=lua_ref(state,1);
>          lua_unref(state,ref);
>          lua_gc(state,LUA_GCCOLLECT,0);
>  }
>
>  I observe ref is returned like this
>
>  iteration 1  ref is 1
>  iteration 2  ref is 1
>  iteration 3  ref is 2
>  further iterations increase ref by 1

I tried to reproduce your problem in Lua 5.1, but could not do so.  I
also looked at the Lua code in question and couldn't figure out what
could cause this.

What version of Lua are you using?  More importantly, how are you
inspecting the return values of lua_ref()?  Are you stepping through
this code in a debugger, or is there more to your program than you
pasted here?

Note that the lua_ref compatibility macro simply calls luaL_ref, using
the registry as the reference table.  If you use integer keys in the
registry for your own purposes, this will conflict with lua_ref().

Greg F