tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: [patch] remove luactl require



So, adding a bit to this:

1. We remove 'luactl require': Lua function require should be used
instead. For loadable modules, lua(4) require implementation autoloads
the module if needed.

    Patch at [0]

2. We provide an option (e.g., -s) to 'luactl create' to allow
creating a state with standard libraries preloaded. The default
behavior remains the same: a state is created empty

    So, for instance:
       `luactl -s create s0` would create s0 and then open standard
libraries in it (i.e., luaL_openlibs(L))

    Patch at [1]

3. We extend lua(4) require implementation so that, if given a
standard library name as argument, it opens that module

    So, if a script issues 'require"io"', function `luaL_requiref(L,
"io", luaopen_io, 1)` will get called; same goes to any of the
standard modules, including base lib -- as defined in linit.c,
loadedlibs array. (Some of them are not supported in kernel Lua yet,
but they will be soon!)

    Patch at [2]

Please share your thoughts

[0] https://netbsd.org/~salazar/patches/bye_require.patch
[1] https://netbsd.org/~salazar/patches/luactl_openlibs_create.patch
[2] https://netbsd.org/~salazar/patches/lua4_require_stdlibs.patch

On Sat, May 21, 2016 at 4:21 PM, Guilherme Salazar <salazar%netbsd.org@localhost> wrote:
> Hi,
>
> [1] is a patch that removes luactl command to require a module; as
> Mark suggested, it should be up to the script being loaded to issue
> 'require' on modules.
>
> [1] https://netbsd.org/~salazar/patches/bye_require.patch
>
> Comments?


Home | Main Index | Thread Index | Old Index