lua-users home
lua-l archive

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

On 16/02/2010, at 12:12 PM, David Burgess wrote:

> Any news on the 5.2 front?

I haven't seen any comment on my message in an earlier thread, that the following code:

local env = {}
local f = assert (loadfile ("config.lua"))
setfenv (f, env) ()

... which lets you load a configuration file into a table, will no longer work under Lua 5.2.

Excepting that you use the io library (which you may not even want to include, or have reservations about allowing the use of, due to the ability to read/write to arbitrary files on the user's file system).

My suggested fix was allowing the passing in of an environment into loadfile, eg.

local env = {}
local f = assert (loadfile ("config.lua", env)) ()

- Nick