lua-users home
lua-l archive

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


On Mon, Apr 6, 2015 at 7:36 PM, Dibyendu Majumdar
<mobile@majumdar.org.uk> wrote:
> Hi,
>
> Apologies if this is going over old ground ... I have been thinking
> about how to allow fast metamethods for userdata objects. As userdata
> objects are created by C code then it is possible for C code to
> provide an array of C functions (like a C++ vtable) for the userdata
> object - the C functions to be used as metamethods.
>
> What would be reason for not doing it this way?
>
> I am interested in this as I want to achieve high performance for
> certain operations involving userdata types - which otherwise means I
> have to make the VM recognize these types so that it can perform
> operations on these types natively. However that approach isn't
> scalable as enhancing the VM to recognize new types is a lot of work.
>
> Thanks and Regards
>
> Dibyendu
>

I'm not sure what you're proposing. The metatable is already a list of
functions to call for various events. Are you suggesting that the
metamethods be stored in an array instead? I think Lua already does
something like that internally when you assign the metatable.

-- 
Sent from my Game Boy.