[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: CONSTANTS patch - LKBIT
- From: "Juris Kalnins" <juris@...>
- Date: Tue, 28 Sep 2010 08:29:13 +0300
On Tue, 28 Sep 2010 04:34:06 +0300, Nilson <nilson.brazil@gmail.com> wrote:
Hi guys,
New feature on the horizon: CONSTANT behavior in lua
...
What exactly are the semantics of the functions that you propose?
What is the intended use of such feature?
myprint = function(...) print('Hi',...) end
_G.print = lkset(_G.print) -- protects against accidental change
_G.print = myprint
error: attempt to change a locked value: function: 004755D8
so what exactly gets locked -- value of function 'print' or value
at the key 'print' in table _G?
i.e:
local a = lkset({}) -- is a locked?
local b = { k = a } -- is b.k locked?
local c, d = {}, {}
c.k = {}
d.k = c.k
c.k = lkset(c.k) -- is d.k locked now?
c.k.v = 1 -- does this work?
setmetatable(c.k, evil_metatable) -- does this work?