lua-users home
lua-l archive

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


>is it also possible to unload or garbage-collect code that is no longer needed?

Code is treated just any other value: it's garbage-collected when there are no
references to it.

So, for instance, in
	function f() print"ok" end
	f()
	f=22

The function create in this chunk will be collected next time GC runs.

If your functions are stored in global variables, just setting those variables
to nil wil mark the functions to be collected.

(All this explanation works for all kinds of values, not just functions.)
--lhf