Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to call erlang function from lua file? #76

Open
ziyouchutuwenwu opened this issue Apr 18, 2017 · 1 comment
Open

how to call erlang function from lua file? #76

ziyouchutuwenwu opened this issue Apr 18, 2017 · 1 comment

Comments

@ziyouchutuwenwu
Copy link

how does lua call erlang? for example, lua want to send socket throuth erlang, or tell other node some info by erlang, how to do this? i don't know how to do it.

@rvirding
Copy link
Owner

You cannot directly call Erlang from the Lua inside luerl. To do this you need to define an interface module written in Erlang with functions you can call from Lua. There is a predefined way of building and loading such a module so it can be reached from Lua through a table like any other Lua function. There is also a predefined way of passing data in and out of these functions. If you look in the src directory all the modules luerl_lib_XXXX.erl are interface modules like this. If you check in the module luerl_emul.erl in the function load_lib/3 you can see how it is installed.

None of this is secret in any way but it just hasn't been documented.

One reason for having it this way is that it makes sandboxing very easy as Lua code cannot do this loading, it has to be done in the surrounding Erlang. Which makes it trivial to set up a limited environment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants