[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Deep __newindex on assignment?
- From: Peter Cawley <lua@...>
- Date: Tue, 22 Dec 2009 18:50:51 +0000
On Tue, Dec 22, 2009 at 6:40 PM, Todd Berkebile
<todd_berkebile@hotmail.com> wrote:
> local pos = propBag.Position -- pos is now the proxy object wrapping the Point userdata
> pos.z = 10 -- this will use the proxy's __newindex thus setting the value in propBag
> otherBag.Position = pos
> assert(propBag.Position ~= otherBag.Position) -- this would fail as both were modified
>
> With the above syntax I wouldn't want the original propBag to be modified.
Why not? To me (and effectively to the Lua compiler), the following
two bits of code are equivalent:
---------
local temp = propBag.Position
temp.z = 10
---------
propBag.Position.z = 10
---------
Hence in both cases, I would want the original propBag to be modified.