[PATCH v2 1/2] schema: move space_mt and index_mt definition out of space bless
vdavydov.dev at gmail.com
Sun Apr 1 12:33:52 MSK 2018
For the record, as I said before
> I don't understand why anyone would do that. If one wants to
> implement some extra methods, they can always create a wrapper
> in Lua. Overwriting a metatable for this looks like a dirty hack.
so this is a purely technical review.
On Thu, Mar 29, 2018 at 05:31:44PM +0300, Vladislav Shpilevoy wrote:
> +function space_mt:len()
> + check_space_arg(self, 'len')
> + local pk = self.index
> + if pk == nil then
> + return 0 -- empty space without indexes, return 0
> - space_mt.len = function(space)
> - check_space_arg(space, 'len')
> - local pk = space.index
> - if pk == nil then
> - return 0 -- empty space without indexes, return 0
> - end
> - return space.index:len()
> - end
This isn't what I meant when I wrote
> move index_mt and space_mt definitions from box.schema.space.bless
> without introducing any functional changes, then export them
I meant that in the first patch you should just move these functions to
the top-level, without doing ANY changes to them, otherwise the patch
will be rather difficult to review.
Anyway, I don't think the piece of syntax sugar you're trying to push
(passing the object to a class method implicitly) is really necessary.
We never do it in schema.lua, why do it for space_mt/index_mt now?
And it's definitely doesn't belong to this patch. Please remove.
> diff --git a/test/box-tap/schema_mt.test.lua b/test/box-tap/schema_mt.test.lua
The test should go to patch 2, the one that exports the metatables.
More information about the Tarantool-patches