From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: "Basil L. Contovounesios" Newsgroups: gmane.emacs.bugs Subject: bug#23736: Add companion to apply-partially Date: Sun, 28 Jul 2019 14:59:34 +0100 Message-ID: <87r26al0op.fsf@tcd.ie> References: <87mvmuzciw.fsf@gmx.us> <87zhkybbz0.fsf@mouse.gnus.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="84615"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: 23736@debbugs.gnu.org, Rasmus To: Lars Ingebrigtsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Jul 28 16:00:10 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hrjic-000Luv-0Y for geb-bug-gnu-emacs@m.gmane.org; Sun, 28 Jul 2019 16:00:10 +0200 Original-Received: from localhost ([::1]:45376 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hrjib-0006to-1T for geb-bug-gnu-emacs@m.gmane.org; Sun, 28 Jul 2019 10:00:09 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:39598) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hrjiW-0006tg-DW for bug-gnu-emacs@gnu.org; Sun, 28 Jul 2019 10:00:05 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hrjiV-0002vT-Bt for bug-gnu-emacs@gnu.org; Sun, 28 Jul 2019 10:00:04 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:38089) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hrjiU-0002tW-WD for bug-gnu-emacs@gnu.org; Sun, 28 Jul 2019 10:00:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hrjiU-0007NW-Nj for bug-gnu-emacs@gnu.org; Sun, 28 Jul 2019 10:00:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: "Basil L. Contovounesios" Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 28 Jul 2019 14:00:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 23736 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: wontfix Original-Received: via spool by 23736-submit@debbugs.gnu.org id=B23736.156432238828316 (code B ref 23736); Sun, 28 Jul 2019 14:00:02 +0000 Original-Received: (at 23736) by debbugs.gnu.org; 28 Jul 2019 13:59:48 +0000 Original-Received: from localhost ([127.0.0.1]:46910 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hrjiF-0007Me-P2 for submit@debbugs.gnu.org; Sun, 28 Jul 2019 09:59:48 -0400 Original-Received: from mail-wr1-f66.google.com ([209.85.221.66]:46069) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hrjiA-0007MP-MA for 23736@debbugs.gnu.org; Sun, 28 Jul 2019 09:59:46 -0400 Original-Received: by mail-wr1-f66.google.com with SMTP id f9so58979678wre.12 for <23736@debbugs.gnu.org>; Sun, 28 Jul 2019 06:59:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tcd-ie.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-transfer-encoding; bh=J1EQUax9m6Kh7+AzuKZluZMD0Qu76JDBnmp4rBo/LGQ=; b=ywu1tZEUJk774tlr/vOo+13n6L35EOwPhHuX2B7Q9XGHf5sL1d2597TVB/gUUnfUIe ctUePo2L+EncEJPEC5X1Wy895BaPvbaHBo3mWag3elnPLQfu/aZSMwkAsnKT7GdIeRZp /BMMK46NhhkDqyleRizHeQm7fGZ3ag2RV1gINe389TXhUj/751JbuaXN6vNJqRJQCwXT SALBP02lHD6PLaxb+ewhJ7uHjHldWb6PDI0Yx7Y0G598OY5h7MCktQXjB+eGsoNicH1f yZ8Cn9W4k4vVsCr+R1HA9IusrDcYy5NHnmhWMQCnC3MEVxh3X0oXiOT/MMCd1pWFAil9 B+gQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-transfer-encoding; bh=J1EQUax9m6Kh7+AzuKZluZMD0Qu76JDBnmp4rBo/LGQ=; b=HKmMBbI3eHUir9jqko8vdxZAbdJO8p5CiWP8Qyky8DzzXu/EFMsFLorh4MsLuyBuQo CO+Okarixeh4WPFxDn1uNXLFDZvBtRkydWpb/pXAsXLTvuRWVI5Wl0It8W7YayvBjZJ0 BW1ZVmgl0OhnFPmOOozbc4YiZZqKkVzZLmP1RF2K6rMkubOMz/q02gMqoMyzWAVoH+JZ 8LM1fiHzNYCeeThV1AxyvCWCR8adtaTWHB0PQkG4Tqk3SBoRhsCohnmP1YDmW1c7iLE1 PIah17nZ4bvGm4hbstKsyljiwUJDB6zsjapJwb3MkliOIWvYziGXji4uQ29faeH5QaGc eGLg== X-Gm-Message-State: APjAAAUupJNZ20uuI8bAKqMCystOo9S95ZvcSofmkejkBGx9IoUiMp/q 38SFswUdIA/skLPT4XjzhLrXRg== X-Google-Smtp-Source: APXvYqwXGfgiYa72V6y3ntXlhKY2JjCDqkFxyx1eJIWJMQyy74303qrhMfziwjV9z2ApQFaY+OU/Yg== X-Received: by 2002:a5d:4e08:: with SMTP id p8mr38575501wrt.20.1564322376802; Sun, 28 Jul 2019 06:59:36 -0700 (PDT) Original-Received: from localhost ([2a02:8084:20e2:c380:1f68:7ff5:120d:64e]) by smtp.gmail.com with ESMTPSA id t15sm51099448wrx.84.2019.07.28.06.59.35 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sun, 28 Jul 2019 06:59:35 -0700 (PDT) In-Reply-To: <87zhkybbz0.fsf@mouse.gnus.org> (Lars Ingebrigtsen's message of "Sun, 28 Jul 2019 14:05:55 +0200") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:163956 Archived-At: Lars Ingebrigtsen writes: > Rasmus writes: > >> Could we add an =E2=80=98apply-rpartially=E2=80=99 or =E2=80=98apply-par= tially-last=E2=80=99 to subr.el? >> Like =E2=80=98apply-partially=E2=80=99, but fixing the last arguments. = This is useful for >> e.g. =E2=80=98set-face-attribute=E2=80=99 where one might a common :inhe= rits to many >> faces, e.g. >> >> (mapc (apply-rpartially =E2=80=99set-face-attribute :inherit =E2=80= =99fixed-pitch) =E2=80=99(list of faces)) >> >> I have used this in my init.el, >> >> (defun apply-rpartially (fun &rest args) >> "Return a function that is a partial application of FUN to ARGS. >> ARGS is a list of the last N arguments to pass to FUN. The >> result is a new function which does the same as FUN, except that >> the last N arguments are fixed at the values with which this >> function was called." >> (lambda (&rest args1) >> (apply fun (append args1 args)))) > > (I'm going through old Emacs bug reports that haven't received any > response.) > > I think this sounds like a slightly too obscure function to add to Emacs > core. apply-partially is more useful because functions are often > constructed in ways that makes that a convenient function, while the > opposite order is more unusual, I think? Indeed I think partial application from the right is not as generally useful in languages with variadic functions. IME it is often replaced with shorthand for closures or currying from the right. In the case of Elisp there is also the issue that apply-partially is both a little verbose and (currently) significantly less efficient than an open-coded closure. --=20 Basil