lua-users home
lua-l archive

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

Am 16.04.2013 04:36 schröbte Miles Bader:
Philipp Janda <> writes:
   if _VERSION == "Lua 5.1" then
     setfenv( f, env )

BTW, it seems much cleaner to just do:

    if setfenv then setfenv (f, env) end

Yes, but (related to another thread) I do

local setfenv = setfenv
if _VERSION == "Lua 5.1" then
  assert( setfenv )

at the top of the file anyway, and some people have written setfenv[1][2][3] for Lua 5.2 and I feared that one of those functions could end up in the global environment, or -- even worse -- that someone wrote a completely unrelated function with that name, since the name setfenv is fair game now in Lua 5.2.