lua-users home
lua-l archive

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

So just strict typing. That could be done with metatables.
On 5 Nov 2021, 13:10 +0300, 云风 Cloud Wu <>, wrote:
Spar <> 于2021年11月5日周五 下午5:35写道:

The way lua values are made in C is best for dynamic typing. No matter if it's a number or a table, they allocate the same size in memory with type info.
Making it space efficient still needs metadata for the content and type checking. And maybe it won't be even performing because of that. LuaJIT has similar thing: ffi C definitions. But it's advantage is JIT compilation which makes the access to the structure in the most efficient way.

The way I mentioned for the tuple is dynamic typing, too. The
limitation is not changing types after creating.

The type info of tuples will store in a separating string object that
can be shared by short string intern mechanism, and the values can be
packed into a continuous memory (4 or 8 bytes per value without type
byte) .