lua-users home
lua-l archive

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

On Wed, Aug 3, 2011 at 13:41, Dirk Laurie <> wrote:
> 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.
> Dirk

Can't you use setfenv to load in an empty environment in 5.1?

Sent from my toaster.