[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: __newindex setting table
- From: Duncan Cross <duncan.cross@...>
- Date: Fri, 30 Jun 2017 10:11:46 +0100
On Fri, Jun 30, 2017 at 9:50 AM, Victor Bombi <sonoro@telefonica.net> wrote:
> Hi,
>
> Where in the docs can be infered that
>
> local aa = metatable({},{__newindex = function(t,i,v) t=v end})
>
> aa[0] = 24
>
> is not performing aa = 24
>
> Best
> victor bobi
>
2.1 - Values and Types
"Tables, functions, threads, and (full) userdata values are objects:
variables do not actually contain these values, only references to
them. Assignment, parameter passing, and function returns always
manipulate references to such values; these operations do not imply
any kind of copy."
So, in your case, the parameter "t" and the variable "aa" are seperate
references, -- reassigning one reference does not affect the other.
-Duncan