[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Could metatables easily be faster?
- From: 云风 Cloud Wu <cloudwu@...>
- Date: Fri, 20 May 2022 15:39:49 +0800
Flyer31 Test <firstname.lastname@example.org> 于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