lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Tue, Oct 20, 2020 at 4:04 AM 孙世龙 sunshilong <sunshilong369@gmail.com> wrote:
>
> >there are lua objects,just not gc object.
> LUA_TBOOLEAN、LUA_TLIGHTUSERDATA and LUA_TNUMBER are not gc objects?

No, they're not objects, they're just values. When you assign them you
make a copy.

When you assign an object, say in a statement like "b = a", both 'a'
and 'b' refer to the same object. This is not different from most
programming languages (Java for instance).
When you compare objects "a == b" only returns true if 'a' and 'b'
refer to the same object.

Strings are a bit different, because they're immutable, once created
they can't change, they act like values although they're garbage
collected, "a == b" returns string equality, even if these two strings
are not the same object in the interpreter (this will only happen for
long strings, over 32 bytes I think).


Gé