lua-users home
lua-l archive

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

On Wed, Jan 21, 2009 at 5:51 PM, František Fuka wrote:
> But this also doesn't work because the order is
> significant. I have to call the test_function() functions in exactly the
> same order their filenames are present in the original array.

Something like this may do:

Iterate over the package names in package.loaded.  Convert each
package name to a file name by consulting the package.path variable in
the same manner that require does so.  (For an idea of how you might
do this see or .)  Storing the inverse mapping
of this in a table allows you to determine package names(s) that map
to a given file name.

Then iterate over the table of file names.  For each file name,
convert it into a package name by consulting the map above.  Do
require(package_name) (note: calling require twice has no side-effect)
and store the return value, which is the package table.  Call the
test_function() inside it or, to find MODULENAME (which might differ
from the package name passed to require), lookup inside package.loaded
for a MODULENAME having a package table matching this package table.