lua-users home
lua-l archive

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


> > Does anyone still use references in real applications? For what?
> 
> I use it when I need to pass a callback to a C library, that could be
> triggered in a subsequent lib call (ie. I can't just let a value on
> the stack). I allocate a small struct { lua_State* L; int ref },
> create a ref to the callback (a Lua "function" passed by the binding
> user) and pass its address as the callback void*.

Instead of a reference, can't you use the address of this small
structure as the key to the callback (as a light userdata)? Or the
address of a dummy 'ref' field, if you must keep more than one
reference?

(PS: I am aware I am not being strick to my question: there is a
difference between whether people use references and whether people need
references...)

-- Roberto