lua-users home
lua-l archive

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

-----Original Message-----
From: Ando Sonenblick []
Sent: Wednesday, October 15, 2003 1:14 PM
To: Lua list
Subject: lua_ref's... how to?


Can someone give me a quick overview (or direct me to a page) that
describes what lua_refs can do?  I've been looking for details on them,
but most web pages mention them without giving a "here's what and how"
about them...

They're also not in the 5.0 manual (that I was able to find).

FYI, what I'm hoping they'll be useful for is something like this: I'd
like to store an arbitrary lua type (be it a variable, a table, a
function, etc) in my C code for later use.

So Ideally, I could

        myCPPObject->luaRef = lua_ref(L, true)      -- take whats on the top
of the stack and make a ref

then, later in my C code, I can then use that:

        lua_getref(myCPPObject->luaRef);                    -- push the contents of
the ref
        <call a lua routine>

and then when done, no longer reference it:


Is this how lua ref's work?


Ando Sonenblick
SpriTec Software