[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Lua and C - misc questions
- From: Ben Sunshine-Hill <sneftel@...>
- Date: Sat, 20 Aug 2005 18:46:27 -0700
On 8/20/05, Diaa Sami <email@example.com> wrote:
> 1- how to remove a value from the globals table
> so, now I want to know how to remove this variable so
> that it's not available to lua code anymore.
Just set a nil as the value for the same key.
> 2- how to un-register a function
> I've registered a function using the macro
> how to un-register the function so that it can't be
> called from lua anymore.
Ditto. Assign a nil to the same global name.
> 3-how to remove all the variable associated with a
> chunk(i.e. unload the chunk and all associated data
> and functions).
> I loaded a chunk using luaL_loadfile(), and everything
> went fine.
> I reached a point in the program where I don't want
> that loaded chunk, I want to discard it and all the
> associated data, how to do this?
Remove all references to the chunk (possibly by copying nil over
them!) and the garbage collector will unload it. Note that that will
not discard the "associated data" if references to that data exist
elsewhere in the lua space.
> 4- how to make global variables read-only?
> I heard it is possible to make variables read-only in
> lua, how can I do this?
> 5- how to get a table's length?
Those I don't recall. Anyone else?