lua-users home
lua-l archive

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

I'm sorely missing lfs for Lua 5.2.

The app does this:

    - for every file in a directory, try to run it as Lua code
    - if successful, make a table of everything it adds to its environment
        and store that (indexed by the filename) in another table `catalog`

Part 1 needs lfs, but lfs is only available up to Lua 5.1.
Part 2 is easiest with Lua 5.2's version of load: run the file contents in
    an empty environment and that's the required table.

The Lua 5.1 code for Part 2 is truly horrid: I make a table called `snapshot` 
with the current global names, run the file, identify the new keys by 
checking which global names do not occur in `snapshot`, record them in a new 
table (that's the one for the catalog) and delete them from _ENV.