[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Deep __newindex on assignment?
- From: Alexander Gladysh <agladysh@...>
- Date: Wed, 23 Dec 2009 01:38:51 +0300
>> 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)?
> Very similar to Java, which is classically called pass by value for
> primitives (numbers) and pass by reference for objects (tables). The
> pass by reference bit is a misnomer though, it's really "references
> passed by value" but that's a mouthful.
> In C terms, Lua variables behave exactly like normal ints and pointers
> do. A variable either holds a value, like 1, 4, or 77, or a pointer
> to a table. If two pointers point to the same table, changes made via
> one pointer are reflected when accessed via the other.
> I guess the key point is that although we generally talk of a variable
> as being a table, it's really a pointer/reference to a table.
Okay, thanks, a good one.
Your definition is based on references to other languages (and that's
really useful for getting the message).
But I'm also looking for is a more formal one.
Also, can Lua variable-to-value relationship be defined with a single
clause for all value types, both objects and primitives?