[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Deep __newindex on assignment?
- From: Alexander Gladysh <agladysh@...>
- Date: Wed, 23 Dec 2009 01:01:30 +0300
> Some people feel it is wrong to say so, but if it helps you to
> understand the Lua model, then you can think that complex objects
> (tables and userdata) are always passed/copied by reference, whereas
> simple objects (numbers, strings, etc.) are always passed/copied by
> A different way to think of things is slightly more removed from how
> things are in C. Consider the set of values, and the set of variables
> to be separate, and think of variables as binding to values. In your
> first example, a is bound to the value 10, then b is bound to 10, then
> b is bound to 11. In your second example, In your second example, you
> create a table value, bind the "member" field of this table to 10,
> then bind the variable a to this table. Then you bind b to the value
> bound to a.member, i.e. you bind b to 10. Then you bind b to 5.
BTW, does any one know more strict/formal definition for the way Lua
values and variables are bound together (including assignment and
function argument / return value passing)?
Related questions are rather popular topic for people coming to Lua
from C++ side. I'd like to be able to aswer it better. :-)