lua-users home
lua-l archive

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


2010/1/8 Mike Pall <mikelu-1001@mike.de>:
> Roberto Ierusalimschy wrote:
>> Yes. The semantics is exactly as Mark explained:
>>
>>   in t do command end
>>
>> is translated to
>>
>>   do
>>     local _temp = t;
>>     <command>
>>   end
>>
>> and all acesses to <global> inside command are changed to _temp.global.
>
> Sadly we don't get development snapshots for Lua 5.2. So I've
> created a backport patch against Lua 5.1.4 from the above
> description. It's entirely unsupported of course.
>

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.

Matthew