bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#49316: Add apply-partially's right version


From: Stefan Monnier
Subject: bug#49316: Add apply-partially's right version
Date: Sun, 24 Oct 2021 10:28:14 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

Lars Ingebrigtsen [2021-10-24 15:47:00] wrote:
> Eli Zaretskii <eliz@gnu.org> writes:
>> As for the rest, I'd like Lars to state his opinion about this new
>> function.  AFAICT, he didn't say what he thinks here.
>
> I'm not very enthusiastic -- is partial application used a lot now that
> we've got lexical binding?  Partial application has always seemed like
> One Weird Trick to me.

Like Stefan, I don't find partial application weird.
But I'm not sure what's the advantage of

    (apply-rpartially #'foo x y)

over

    (lambda (a b) (foo a b x y))

It's not necessarily shorter, it's less flexible (the lambda form lets
you pass args in the middle), and it's less efficient (it necessarily
relies on `&rest`, `append/nconc` and `apply`, which imply allocating
lists).

[ And with prettify-symbols-mode the lambda version is even shorter.  ]

> On the other hand -- some people are used to programming using these
> idioms, so perhaps it makes sense to add a right version as well?

`apply-partially` was handy before we had `lexical-binding`, but
I wouldn't have added it to Emacs after Emacs-24.
We already have `dash.el` for those users who like this style.


        Stefan






reply via email to

[Prev in Thread] Current Thread [Next in Thread]