From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS31976 209.132.180.0/23 X-Spam-Status: No, score=-3.9 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI shortcircuit=no autolearn=ham autolearn_force=no version=3.4.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by dcvr.yhbt.net (Postfix) with ESMTP id 01F5E1F453 for ; Wed, 17 Oct 2018 08:33:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727040AbeJQQ2S (ORCPT ); Wed, 17 Oct 2018 12:28:18 -0400 Received: from cloud.peff.net ([104.130.231.41]:43186 "HELO cloud.peff.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1726967AbeJQQ2S (ORCPT ); Wed, 17 Oct 2018 12:28:18 -0400 Received: (qmail 16276 invoked by uid 109); 17 Oct 2018 08:33:42 -0000 Received: from Unknown (HELO peff.net) (10.0.1.2) by cloud.peff.net (qpsmtpd/0.94) with SMTP; Wed, 17 Oct 2018 08:33:42 +0000 Authentication-Results: cloud.peff.net; auth=none Received: (qmail 18177 invoked by uid 111); 17 Oct 2018 08:32:53 -0000 Received: from sigill.intra.peff.net (HELO sigill.intra.peff.net) (10.0.0.7) by peff.net (qpsmtpd/0.94) with (ECDHE-RSA-AES256-GCM-SHA384 encrypted) SMTP; Wed, 17 Oct 2018 04:32:53 -0400 Authentication-Results: peff.net; auth=none Received: by sigill.intra.peff.net (sSMTP sendmail emulation); Wed, 17 Oct 2018 04:33:41 -0400 Date: Wed, 17 Oct 2018 04:33:41 -0400 From: Jeff King To: =?utf-8?B?UmVuw6k=?= Scharfe Cc: Derrick Stolee , Derrick Stolee via GitGitGadget , git@vger.kernel.org, Junio C Hamano , Derrick Stolee Subject: Re: [PATCH 15/16] commit-reach: make can_all_from_reach... linear Message-ID: <20181017083340.GB31932@sigill.intra.peff.net> References: <223b14f7-213f-4d22-4776-22dcfd1806c2@web.de> <7b95417a-c8fb-4f1e-cb09-c36804a3a4d0@web.de> <20181005165157.GC11254@sigill.intra.peff.net> <20181005190847.GC17482@sigill.intra.peff.net> <20181005194223.GA19428@sigill.intra.peff.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org On Sun, Oct 14, 2018 at 04:29:06PM +0200, René Scharfe wrote: > Anyway, drove the generative approach a bit further, and came up with > the new DEFINE_SORT below. I'm unsure about the name; perhaps it should > be called DEFINE_SORT_BY_COMPARE_FUNCTION_BODY, but that's a bit long. > It handles casts and const attributes behind the scenes and avoids > repetition, but looks a bit weird, as it is placed where a function > signature would go. > > Apart from that the macro is simple and doesn't use any tricks or > added checks. It just sets up boilerplate functions to offer type-safe > sorting. > > diffcore-rename.c and refs/packed-backend.c receive special treatment in > the patch because their compare functions are used outside of sorting as > well. I made them take typed pointers nevertheless and used them from > DEFINE_SORT; the wrapper generated by that macro is supposed to be > private. Given that such reuse is rare and I think we don't need a way > to make it public. > > What do y'all think about this direction? I think it's the best we're likely to do, and is an improvement on the status quo. The patch looks overall sane to me. I think DEFINE_SORT() is a fine name. I think given a macro parameter "foo" you could generate sort_by_foo() and compare_foo(), which would eliminate the extra layer in those two cases you mentioned. But I'm also fine with the approach you've shown here. -Peff