lua-users home
lua-l archive

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

On Tue, Jun 17, 2003 at 09:27:47PM +0400, Grisha wrote:
> Thank you very much, but there's no word about this method in documentation.
> Can you say, what does it do exactly?
> > handle=luaL_ref(st, LUA_REGISTRYINDEX)

LUA_REGISTRYINDEX is a pseudoindex for/points to to a table called 
'registry', which is intended for C code to store Lua objects/values
it might later need. luaL_ref simply allocates a slot from the 
positive integer indices for the object at top of the stack 'st' 
and pops it from the stack. Alternatively you could use any other
table than the registry. There are also the macros lua_ref and 
lua_unref for backwards-compatibility as 4.x (and older?) used to
have a special reference mechanism for this purpose. 

PS. You should use luaL_unref to free the handle when you no longer
need it.