From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-3.5 required=3.0 tests=AWL,BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 934141F5AF for ; Fri, 10 Jul 2020 18:38:14 +0000 (UTC) Received: from localhost ([::1]:57674 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jtxuX-0007Uv-6X for normalperson@yhbt.net; Fri, 10 Jul 2020 14:38:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46602) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jtxuO-0007Jv-4q for bug-gnulib@gnu.org; Fri, 10 Jul 2020 14:38:04 -0400 Received: from mo4-p00-ob.smtp.rzone.de ([81.169.146.217]:23227) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jtxuL-00073r-C0 for bug-gnulib@gnu.org; Fri, 10 Jul 2020 14:38:03 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1594406279; s=strato-dkim-0002; d=clisp.org; h=References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: X-RZG-CLASS-ID:X-RZG-AUTH:From:Subject:Sender; bh=TUsr8mHUOsGLHJuFQB6xoH5WkYa7pq09T0/YHO9DODo=; b=E/LiuWPweQxKhkl+qsClI04xm7WiEPFfB3WxVh+/xWEbM6heiFHqMog2u7EOJ8SFey 3g/4ofAbgk4o5RhoJkoK7alHor0PLV9T7p/iu2syU0D8Oyt1Eobms6ILzDWvZ5SocIjC OKHFilvpS7IH++8OyWpekFnjwQZB58OlKPsPQm5LiWsaJU/iloGRYTz5i1jmZGzcpHxO CF0iJggvJ73On46F44ajMCnK7jfoiOkFTe3efxJJDT6hDnon227X38EEqNDQtChppWYr Ajsbn6s0mv0KFV26/ytyyg3Bg33diIOvODrSRtUN3N7FhKkD98i1QcR4a6Ejl9SCvHi0 PV8Q== X-RZG-AUTH: ":Ln4Re0+Ic/6oZXR1YgKryK8brlshOcZlIWs+iCP5vnk6shH+AHjwLuWOH6fzxfs=" X-RZG-CLASS-ID: mo00 Received: from bruno.haible.de by smtp.strato.de (RZmta 46.10.5 DYNA|AUTH) with ESMTPSA id R03d1aw6AIbwceT (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (curve X9_62_prime256v1 with 256 ECDH bits, eq. 3072 bits RSA)) (Client did not present a certificate); Fri, 10 Jul 2020 20:37:58 +0200 (CEST) From: Bruno Haible To: Marc =?ISO-8859-1?Q?Nieper=2DWi=DFkirchen?= Subject: Re: Callbacks in the abstact data types and extra contextual data Date: Fri, 10 Jul 2020 20:37:57 +0200 Message-ID: <66437142.cN4hItpXB1@omega> User-Agent: KMail/5.1.3 (Linux/4.4.0-179-generic; KDE/5.18.0; x86_64; ; ) In-Reply-To: References: <3763750.T6txBgErrX@omega> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Received-SPF: none client-ip=81.169.146.217; envelope-from=bruno@clisp.org; helo=mo4-p00-ob.smtp.rzone.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/10 14:37:59 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-1, SPF_HELO_PASS=-0.001, SPF_NONE=0.001, URIBL_BLOCKED=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: bug-gnulib@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Gnulib discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: bug-gnulib@gnu.org Errors-To: bug-gnulib-bounces+normalperson=yhbt.net@gnu.org Sender: "bug-gnulib" Hi Marc, > > > a number of modules (like the hash module or the list module) allow > > > the user to specify callbacks (e.g. a comparison function). > > > Unfortunately, these procedures do not take a context parameter, which > > > can be a problem because C lacks closures. > > > > Is this a practical, actual problem, or only a theoretical one? > > It is a practical one; in a computer algebra application, I have lots > of small entities (two words each), whose sort order is determined by > the extra data. OK. Then let's take the problem seriously. I think it's time to solve the problem once and for all. I propose to add a module that defines a function 'partial_function_last' such that, when you have a function pointer int (*cmp3) (void *arg1, void *arg2, void *context) then cmp2 = partial_function_last (cmp3, context); produces a function pointer int (*cmp2) (void *arg1, void *arg2) that invokes cmp3 with the given context. Wikipedia calls it "partial function application". The module will also have a function 'partial_function_free' that frees a function that was constructed in this way. Give me a couple of days to implement that. Bruno