-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from tv-labs/readme
Start writing some module docs
- Loading branch information
Showing
4 changed files
with
52 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,43 @@ | ||
# Lua | ||
|
||
Brings all the expected UX of Elixir to Luerl | ||
<!-- MDOC !--> | ||
|
||
Lua is an ergonomic interface to [Luerl](https://github.com/rvirding/luerl), aiming to be the best way to use Luerl from Elixir. | ||
|
||
## Features | ||
|
||
* Ergonomic API for Elixir <> Lua FFI | ||
* Improved error messages | ||
* Deep-setting variables and state | ||
* Excellent documentation and guides for working with Luerl | ||
|
||
## Usage | ||
|
||
### Executing Lua | ||
|
||
Lua can be run using the `eval!/2` function | ||
|
||
``` elixir | ||
iex> {[4], _} = | ||
...> Lua.eval!(""" | ||
...> return 2 + 2 | ||
...> """) | ||
``` | ||
### Exposing Elixir functions to Lua | ||
`Lua` provides the `deflua` macro for exposing Elixir functions to Lua | ||
defmodule MyAPI do | ||
use Lua.API | ||
deflua double(v), do: 2 * v | ||
end | ||
lua = Lua.new() |> Lua.load_api(MyAPI) | ||
{[10], _} = | ||
Lua.eval!(lua, """ | ||
return double(5) | ||
""") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters