[Tarantool-patches] [PATCH 2.X 4/7] module api: luaL_register_module & luaL_register_type

Alexander Turenko alexander.turenko at tarantool.org
Sat Oct 3 06:24:43 MSK 2020


On Fri, Oct 02, 2020 at 07:14:19PM +0300, Timur Safin wrote:
> : From: Igor Munkin <imun at tarantool.org>
> : Subject: Re: [Tarantool-patches] [PATCH 2.X 4/7] module api:
> : luaL_register_module & luaL_register_type
> : 
> : Vlad,
> : 
> : I glanced the patch and doubt these functions need to be exported by
> : Tarantool. These functions neither wrap internals nor provide any
> : performance benefits (e.g. reduce numbers of excess allocations). It
> : would be nice to have such auxiliary interfaces in so called "modulekit"
> : to make third party modules development easier, but I see no problem to
> : borrow this code to merger/key_def as is for now.
> 
> Ok, let me put it another way:
> - we are agreed that this is necessary useful functionality which might 
>   be part of some static library, as part of modulekit?

No.

As a module developer, why do you need to have functions in the
metatable itself, not just in __index?

Why do you need to hide a metatable with __metatable?

Why do you need to register a module in some unobvious way? Just
register it as foo.bar (require('foo.bar') will work) and do `return
{bar = require('foo.bar')}` in foo.lua / foo.c (require('foo').bar will
work). If you want to forbid require('foo.bar'), just do
`package.loaded['foo.bar'] = nil` inside foo.lua / foo.c. (And it is
necessary when you have something relatively complex: two level of
nesting.)

I don't want to discuss it on the level 'I guess it is useful'. You
should understand use cases to advocate it.


More information about the Tarantool-patches mailing list