Re: Lua registry, environment, and threads.
[
Date Prev][
Date Next][
Thread Prev][
Thread Next]
[
Date Index]
[
Thread Index]
- Subject: Re: Lua registry, environment, and threads.
- From: "Juris Kalnins" <juris@...>
- Date: 2010年1月11日 17:20:58 +0200
On 2010年1月11日 17:08:06 +0200, Luiz Henrique de Figueiredo
<lhf@tecgraf.puc-rio.br> wrote:
But I'm feeling 98% sure "in nil do ... end" never will become valid
Lua.
It is valid in 5.2 and it forces (at runtime) that the block does not
contain any references to global variables.
Lua 5.2.0 (work1) Copyright (C) 1994-2008 Lua.org, PUC-Rio
> in nil do a=1 end
stdin:1: attempt to index local '(environment)' (a nil value)
I was wrong, thanks for correcting.
It almost allows non-tables as the environment! Just tried:
local a = newproxy(true)
local print = print
getmetatable(a).__index = function (v, x) print(x) return "ret" end
in a do
print(key1);
(function () print(key2) end) ();
end
Which outputs:
key1
ret
./src/lua: testen.lua:6: environment is not a table: cannot create closure
Kind of sad :(
Userdata works as environment in the 'in .. do .. end', which is great new
feature,
but still doesn't work in closures...
- References:
- Re: Lua registry, environment, and threads., Christian Tellefsen
- Re: Lua registry, environment, and threads., Roberto Ierusalimschy
- Re: Lua registry, environment, and threads., Mark Hamburg
- Re: Lua registry, environment, and threads., Patrick Donnelly
- Re: Lua registry, environment, and threads., Roberto Ierusalimschy
- Re: Lua registry, environment, and threads., Leo Razoumov
- Re: Lua registry, environment, and threads., Petite Abeille
- Re: Lua registry, environment, and threads., Paul Moore
- Re: Lua registry, environment, and threads., Petite Abeille
- Re: Lua registry, environment, and threads., Juris Kalnins
- Re: Lua registry, environment, and threads., Luiz Henrique de Figueiredo