GNU bug report logs - #23736
Add companion to apply-partially

Previous Next

Package: emacs;

Reported by: Rasmus <rasmus <at> gmx.us>

Date: Thu, 9 Jun 2016 14:03:01 UTC

Severity: wishlist

Tags: wontfix

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 23736 in the body.
You can then email your comments to 23736 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#23736; Package emacs. (Thu, 09 Jun 2016 14:03:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Rasmus <rasmus <at> gmx.us>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Thu, 09 Jun 2016 14:03:01 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Rasmus <rasmus <at> gmx.us>
To: bug-gnu-emacs <at> gnu.org
Subject: Add companion to apply-partially
Date: Thu, 09 Jun 2016 16:01:59 +0200
Hi,

Could we add an ‘apply-rpartially’ or ‘apply-partially-last’ to subr.el?
Like ‘apply-partially’, but fixing the last arguments.  This is useful for
e.g. ‘set-face-attribute’ where one might a common :inherits to many
faces, e.g.

    (mapc (apply-rpartially ’set-face-attribute :inherit ’fixed-pitch) ’(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))))

If that’s good I can prepare a patch that also has documentation.  (I
couldn’t find past discussions about such a function)

Rasmus

-- 
Don't slow down Johnny, leave the Cadillac runnin'





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#23736; Package emacs. (Sun, 28 Jul 2019 12:07:02 GMT) Full text and rfc822 format available.

Message #8 received at 23736 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Rasmus <rasmus <at> gmx.us>
Cc: 23736 <at> debbugs.gnu.org
Subject: Re: bug#23736: Add companion to apply-partially
Date: Sun, 28 Jul 2019 14:05:55 +0200
Rasmus <rasmus <at> gmx.us> writes:

> Could we add an ‘apply-rpartially’ or ‘apply-partially-last’ to subr.el?
> Like ‘apply-partially’, but fixing the last arguments.  This is useful for
> e.g. ‘set-face-attribute’ where one might a common :inherits to many
> faces, e.g.
>
>     (mapc (apply-rpartially ’set-face-attribute :inherit ’fixed-pitch) ’(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?

(And especially with lexical support doing this sort of thing is often
easier, anyway.)

So I'm closing this as a "wontfix".

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Added tag(s) wontfix. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Sun, 28 Jul 2019 12:07:02 GMT) Full text and rfc822 format available.

bug closed, send any further explanations to 23736 <at> debbugs.gnu.org and Rasmus <rasmus <at> gmx.us> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Sun, 28 Jul 2019 12:07:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#23736; Package emacs. (Sun, 28 Jul 2019 14:00:02 GMT) Full text and rfc822 format available.

Message #15 received at 23736 <at> debbugs.gnu.org (full text, mbox):

From: "Basil L. Contovounesios" <contovob <at> tcd.ie>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 23736 <at> debbugs.gnu.org, Rasmus <rasmus <at> gmx.us>
Subject: Re: bug#23736: Add companion to apply-partially
Date: Sun, 28 Jul 2019 14:59:34 +0100
Lars Ingebrigtsen <larsi <at> gnus.org> writes:

> Rasmus <rasmus <at> gmx.us> writes:
>
>> Could we add an ‘apply-rpartially’ or ‘apply-partially-last’ to subr.el?
>> Like ‘apply-partially’, but fixing the last arguments.  This is useful for
>> e.g. ‘set-face-attribute’ where one might a common :inherits to many
>> faces, e.g.
>>
>>     (mapc (apply-rpartially ’set-face-attribute :inherit ’fixed-pitch) ’(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.

-- 
Basil




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Mon, 26 Aug 2019 11:24:06 GMT) Full text and rfc822 format available.

This bug report was last modified 5 years and 356 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.