lua-users home
lua-l archive

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


Flyer31 Test <flyer31@googlemail.com> 于2022年5月20日周五 15:11写道:
>
> So you mean, this would work already for current Lua 5.4? Without
> change of Lua source code?

No. But I think it's easy to patch lua source to support it.

>
> Sorry for too many questions... I do not really understand how you
> would use "fixed userdata" to instruct Lua to "overlay customized
> operators" (this is what metatables essentially do, as I see it. BTW

We can use userdata version metatable for some typical cases, and
support table version metatable simultaneously.

For example, If we need __index and __newindex metamethod only , we
can convert the table (with __index/__newindex keys)
into a fixed structure userdata (by the library), and use it as the
metatable. Trigger these two metamethods would be faster than the
original metatable.


-- 
http://blog.codingnow.com