lua-users home
lua-l archive

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


> I'm interested whether the patch is correct. From the other thread I
> thought I understood that functions would stop using the environment
> they were defined in by default, and instead the environment they are
> called in. Such that this simple example would fail (due to lack of
> print in env):
> 
>    function sayhello() print("Hello") end
>    env = { sayhello = sayhello }
>    in env do sayhello() end
> 
> Am I wrong in my understanding? If so then the change really has less
> consequences than I first thought.

% lua
Lua 5.2.0  Copyright (C) 1994-2008 Lua.org, PUC-Rio
>
>    function sayhello() print("Hello") end
>    env = { sayhello = sayhello }
>    in env do sayhello() end
Hello