Tarantool development patches archive
 help / color / mirror / Atom feed
From: Vladimir Davydov <vdavydov.dev@gmail.com>
To: Alexander Turenko <alexander.turenko@tarantool.org>
Cc: Kirill Shcherbatov <kshcherbatov@tarantool.org>,
	tarantool-patches@freelists.org
Subject: Re: [tarantool-patches] Re: [PATCH v2 2/2] lua: add key_def lua module
Date: Thu, 4 Apr 2019 17:42:03 +0300	[thread overview]
Message-ID: <20190404144203.6kwt63nyli2pdowe@esperanza> (raw)
In-Reply-To: <20190404120040.pcsnns3l4aw32abv@tkn_work_nb>

On Thu, Apr 04, 2019 at 03:00:40PM +0300, Alexander Turenko wrote:
> > > > > Also, returning 1, 0, -1 to Lua looks uncommon. May be, we'd better
> > > > > introduce 'equal', 'greater', 'less', etc helpers returning bool?
> > > > 
> > > > A function for table.sort(table, func) returns boolean, so it make
> > > > sense. I'm a bit afraid that we'll need to make two calls: say, :less()
> > > > and :equal() to determine an order of tuples strictly. But I cannot
> > > > provide a case where it can be necessary. Are you know one?
> > > 
> > > No, I don't write much code in Lua.
> > > 
> > > However, if we decided to switch to bool return parameter, I'd implement
> > > all possible combinations, i.e. eq, ge, le, gt, lt.
> > 
> > I mean are there cases when we need to check, say t1 < t2 and if it is
> > false then check whether t1 == t2 or t1 > t2? In other words, cases when
> > we need to distinguish all three possible situations. Some algorithms?
> > 
> > I looked throught [1] and it seems it does not contain any reason why
> > <=> operator was added to C++20 except ones related to comparison
> > operations autogeneration.
> > 
> > We can just add :cmp() in addition to all other variants, what do you
> > think?
> > 
> > We can also do the trick: return {eq = <boolean>} from :le() / :ge()
> > instead of true, but this way looks weird.
> > 
> > [1]: http://open-std.org/JTC1/SC22/WG21/docs/papers/2017/p0515r0.pdf
> 
> One example that looks valid: search in a binary search tree, where
> non-leaf nodes hold elements.

Okay, I see, it means that someone might actually need cmp(), not
eq/le/etc, in which case adding all those methods returning bool doesn't
look like a good idea. I tend to think that the API proposed originally
was okay, after all. Let's send an RFC to dev@ and see what others
think.

      reply	other threads:[~2019-04-04 14:42 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-27 14:29 [tarantool-patches] [PATCH v2 0/2] " Kirill Shcherbatov
2019-03-27 14:29 ` [tarantool-patches] [PATCH v2 1/2] lua: add luaT_tuple_new() Kirill Shcherbatov
2019-03-28  9:01   ` [tarantool-patches] " Konstantin Osipov
2019-03-28  9:18     ` Alexander Turenko
2019-04-03 18:01   ` [tarantool-patches] " Vladimir Davydov
2019-04-04  2:51     ` Alexander Turenko
2019-04-04  8:14       ` Vladimir Davydov
2019-03-27 14:29 ` [tarantool-patches] [PATCH v2 2/2] lua: add key_def lua module Kirill Shcherbatov
2019-03-28  2:01   ` Alexander Turenko
2019-03-28  7:38     ` [tarantool-patches] " Kirill Shcherbatov
2019-03-28  8:41     ` Kirill Shcherbatov
     [not found]       ` <6d915212-e80f-4a6d-d884-b838bf25f8a7@tarantool.org>
2019-03-28 11:22         ` Alexander Turenko
2019-04-03 11:10           ` Vladimir Davydov
2019-04-03 11:46             ` Alexander Turenko
2019-04-03 12:01               ` Vladimir Davydov
2019-04-03 13:26                 ` Alexander Turenko
2019-04-04  5:07             ` Alexander Turenko
2019-04-04  8:04               ` Kirill Shcherbatov
2019-04-04  9:05                 ` Vladimir Davydov
2019-04-04 11:46                   ` Alexander Turenko
2019-04-04 14:36                     ` Vladimir Davydov
2019-04-04  8:38               ` Vladimir Davydov
2019-04-04 11:17                 ` Alexander Turenko
2019-04-04 12:00                   ` Alexander Turenko
2019-04-04 14:42                     ` Vladimir Davydov [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190404144203.6kwt63nyli2pdowe@esperanza \
    --to=vdavydov.dev@gmail.com \
    --cc=alexander.turenko@tarantool.org \
    --cc=kshcherbatov@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='Re: [tarantool-patches] Re: [PATCH v2 2/2] lua: add key_def lua module' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox