From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Date: Sun, 1 Apr 2018 12:33:52 +0300 From: Vladimir Davydov Subject: Re: [PATCH v2 1/2] schema: move space_mt and index_mt definition out of space bless Message-ID: <20180401093352.fyl2hq5r2itnahgr@esperanza> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: To: Vladislav Shpilevoy Cc: tarantool-patches@freelists.org, Konstantin Osipov List-ID: 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[0] > + if pk == nil then > + return 0 -- empty space without indexes, return 0 > end > +end > - space_mt.len = function(space) > - check_space_arg(space, 'len') > - local pk = space.index[0] > - if pk == nil then > - return 0 -- empty space without indexes, return 0 > - end > - return space.index[0]: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.