[Tarantool-patches] [PATCH v20 6/7] box: implement box.lib module
Cyrill Gorcunov
gorcunov at gmail.com
Wed Apr 7 19:59:35 MSK 2021
On Mon, Apr 05, 2021 at 06:04:41PM +0200, Vladislav Shpilevoy wrote:
> > `require('box.lib').load(path) -> obj | error`
>
> 1. Implementation in C should allow not to call 'require()' at all. For
> example, you don't call require('box.tuple') to use the tuples. The same
> for lib.
>
> However I don't know what is the current rule for the new modules - force to
> call require() or not. Please, ask Mons what should we do. In case we need to
> force to call require() - I have no idea how to do that TBH, since the module
> is in C really, not in Lua. It is loaded as a part of the executable file
> anyway.
>
> 2. Why can't I use box.lib without calling box.cfg{}? I does not depend on it
> anyhow. For example, box.tuple works fine, require() on .so files works fine,
> even ffi.load() works fine without box.cfg{}. What is the problem with box.lib?
Got rid of it and box.lib works without box.cfg{} call now, I'll send a new version.
>
> > +/** Handle __index request for a module object. */
> > +static int
> > +lbox_module_index(struct lua_State *L)
> > +{
> > + lua_getmetatable(L, 1);
> > + lua_pushvalue(L, 2);
> > + lua_rawget(L, -2);
> > + if (!lua_isnil(L, -1))
> > + return 1;
>
> 6. What is happening here in these 5 lines?
Actually this snippet comes from popen code where
we have wrappers on lua level and test for metamethods.
While it doesn't hurt it makes no much sense in current
code, thanks! Will drop.
And I agree on all comments, will address them and resend
the series. Thanks for review, Vlad!
More information about the Tarantool-patches
mailing list