Closed poga closed 5 years ago
What do you think of passing the vm directly as a parameter? That would remove the need of the vm_callback, and the user could instantiate an unsafe vm on their own. Maybe also keep the normal new which creates the vm automatically.
IMO we should keep it simple and limited.
Every Lua integration is highly coupled and opinionated about how it should interact between Lua and the host environment.
I already kinda regret about the nvm, I really shouldn't reply to issues when I'm super sleepywith_vm
interface. Now every change to the prelude.lua
is a potential breaking change to the user. If they added a global variable __lookup_table
and sometimes later prelude.lua
also added its own __lookup_table
, The user's program will break.
That can be fixed by prefixing those variables with actix_lua or something. I dislike a bit the with_vm but not for those reasons, it almost gives complete access to the vm to the user but not quite, I'd say just let the user create it on his own, the ownership will be passed to actix-lua anyway, there's not much more that one can do with an owned value that will be passed to someone else compared with a borrowed value.
(On the edit) Haha it's ok, I've already done most of the issue but I'm waiting to see what you say about this. What i'm suggesting is not very limited but I think is a lot simpler than the current way. I can wait a little longer anyway.
Yeah, that sounds okay to me. I think it will be fine as long as the Lua state is not accessible to the user after passing it to the LuaActorBuilder
.
yep, after passing ownership it's gone, references are invalidated when a value moves (that is unless someone makes some weird unsafe hack, but then almost anything is vulnerable so it's the same)
rlua
provide an unsafe methodnew_with_debug
for loading debug library into lua state.debug.traceback
is an common requirement for 3rd-party Lua libraries. We can also provide an unsafenew_with_debug
method forLuaActorBuilder
to build aLuaActor
with the debug library.