Lua Objects -> Perl Objects?
unhandyandy opened this issue · 3 comments
unhandyandy commented
Can I define an object with a method in Inline Lua and then call it in Perl?
For example, should I be able to have
__Lua__
local thing = {}
thing.mt = {__index = thing}
function thing.action( x )
return x + 1
end
and then call it in perl by thing->action( 3 )?
unhandyandy commented
Or maybe by
&{$thing->{action}}(3)
hoelzro commented
@unhandyandy This is not currently possible; IIRC, Inline::Lua
marshals objects (including tables) between the Perl and Lua environments, so tables lose their metatable. You can, however, do the $object->{method_name}->(@args)
trick, as long as method_name
is a key of $object
itself and not accessed via a metatable.
unhandyandy commented
OK, thanks.