lua-users home
lua-l archive

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

>From : steve donovan
Subject : Re: A question about function in lua?

On Wed, Apr 14, 2010 at 9:11 AM, Aurora <> wrote:
> In a lua file has many function, I use "luaL_loadfile " load the file,
> then call lua_call to exec the file.
> I want to know when the lua_call function finished,

It will return when it has finished processing the code, with a return
code. You should use lua_pcall, because if you get an error with
lua_call your program with end with that error.

> where is the functions in lua?

The global table (can use _G to access it):

function fun() return 42 end

Now _G['fun'] will reference the function.

> If now I call lua_gc to collect the memory, Will gc release the memory used by the funtions?

No, because they are still referenced by the global table.

steve d

Dear steve,