lua-users home
lua-l archive

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

On Jan 21, 2010, at 7:21 AM, David Given wrote:

> [...] pushenv() would be implemented like this:
> function pushenv(env)
>  local newenv = {}
>  setmetatable(newenv, { __index = env })
>  return newenv
> end

Earlier I had assumed you meant 

function pushenv(env)
 setmetatable(env, { __index = <<some magic to do getenv()>> })
 return env

Otherwise you'd need a way to get the current environment in cases where you just want to make some local dynamic bindings that you want unwound, for example, 

in pushenv {print_level = WARNINGS} do ... end

-- e