lua-users home
lua-l archive

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


Yes, you can load another lua file with 'dofile(...)'.
If you need to check for syntax and/or runtime errors you can also use
'loadfile(...)' and 'pcall(...)'

If you want to have an empty table and do not care wether it is another
table, simply create a new one. The garbage collector will take care of the
old table then.


e.g.
-- create a new table...
table = {}
-- fill table with garbage...
table.something = 'something'
table.number = 1
table[1] = 1.99
table[2].number = 999
-- free the table: create a new one and the rest is done by the garbage
collector
table = {}
-- result: a fresh empty table


If you need the data to be freed now, run a 'collectgarbage()' afterwards.

If you need the table to be the same one for some reasons (for example if
you have more than one reference to it and cannot update all), you can look
in the list archive under the subject "Clearing tables" and "The Clear Table
Saga", there was a discussion about this recently.