[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [Proposal?] Environment stacks
- From: "Thiago L." <fakedme@...>
- Date: Sun, 30 Nov 2014 22:58:50 -0200
On 30/11/14 10:06 PM, Luiz Henrique de Figueiredo wrote:
what if environments had stacks?
We already have that. No need for a keyword.
x=1
print(x)
do
local _ENV={print=print}
x=2
print(x)
do
local _ENV={print=print}
x=3
print(x)
end
print(x)
end
print(x)
The _ENV mechanism was created exactly to allow this kind of thing
without resorting to magic.
Issues:
function() return ("").sub end -- Issue number 1: How am I supposed to
get an environment out of this thing from the string metatable? (seeing
as there's no _ENV and no way to access the env of the scope that
created this function)
do
local type = type
local _ENV = {print=print, tostring = function(i) if type(i) ==
"string" then return ("%q"):format(i) end return ("%s"):format(i) end}
print("Issue number 2: Uh oh! This doesn't get serialized!")
end
--
Disclaimer: these emails are public and can be accessed from <TODO: get a non-DHCP IP and put it here>. If you do not agree with this, DO NOT REPLY.