poga / actix-lua

Safe Lua Scripting Environment for Actix
MIT License
121 stars 13 forks source link

Add unsafe `new_with_debug` method to LuaActorBuilder #18

Closed poga closed 5 years ago

poga commented 5 years ago

rlua provide an unsafe method new_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 unsafe new_with_debug method for LuaActorBuilder to build a LuaActor with the debug library.

Arnaz87 commented 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.

poga commented 5 years ago

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 with_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. nvm, I really shouldn't reply to issues when I'm super sleepy

Arnaz87 commented 5 years ago

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.

Arnaz87 commented 5 years ago

(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.

poga commented 5 years ago

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.

Arnaz87 commented 5 years ago

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)