lua-users home
lua-l archive

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


To quote straight from the Lua 5.4 reference manual, section 2.1:

"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."





On Tue, Oct 20, 2020, 18:37 孙世龙 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.
You mean that they(i.e.
LUA_TBOOLEAN、LUA_TLIGHTUSERDATA and LUA_TNUMBER
 ) are neither "objects" and "gc objects"?

Then what's an object in Lua? Is there a clear definition?
The tables, long strings belong to Lua objects?

Am I right?


On Wed, Oct 21, 2020 at 2:23 AM Gé Weijers <ge@weijers.org> wrote:
>
> On Tue, Oct 20, 2020 at 7:46 AM Roberto Ierusalimschy
> <roberto@inf.puc-rio.br> wrote:
> >
> > > 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).
> >
> > 40 bytes (LUAI_MAXSHORTLEN).
>
> I misremembered, 32 was related to the byte skipping used to speed up
> the string hash (a 5 bit right shift is equivalent to a division by
> 32). The 'step' is calculated as (len >> LUAI_HASHLIMIT)+1.
>
> --
> Gé