Creates a new, empty Lua state and returns an external pointer wrapping that state.
Details
All Lua code is executed within a given Lua state. A Lua state is similar to
the global environment in R, in that it is where all variables and functions
are defined. luajr automatically maintains a "default" Lua state, so
most users of luajr will not need to use lua_open()
.
However, if for whatever reason you want to maintain multiple different Lua
states at a time, each with their own independent global variables and
functions, lua_open()
can be used to create a new Lua state which can then
be passed to lua()
, lua_func()
and lua_shell()
via the L
parameter.
These functions will then operate within that Lua state instead of the
default one. The default Lua state can be specified explicitly with
L = NULL
.
Note that there is currently no way (provided by luajr) of saving a
Lua state to disk so that the state can be restarted later. Also, there is
no lua_close
in luajr because Lua states are closed automatically
when they are garbage collected in R.