Subject: bug#76413: [PATCH] New macro 'compf' for composing functions

From: Eshel Yaron <[email-masked]>
Date: Wed, 19 Feb 2025 20:00:14 +0100

Hi Stefan,

Stefan Kangas <[email-masked]> writes:

> Eshel Yaron via "Bug reports for GNU Emacs, the Swiss army knife of text
> editors" <[email-masked]> writes:
>
>> Tags: patch
>>
>> This patch adds a new macro 'compf' that streamlines the common pattern
>> of function composition.
>>
>> Namely, instead of (lambda (x) (foo (bar (baz x)))), with this macro we
>> can write (compf foo bar baz), which expands to exactly the same form.
>
> Why not name it `compose` as in CL and ELisp?

It's a slightly different construct then Common Lisp's compose, so I
feel like calling it by that name could lead to wrong expectations.
Another option is fcomp instead of compf, BTW, if that seems better.

> How about a function with a compiler macro?

That's a valid alternative, but it'd require quoting function names,
which is slightly less concise/convenient.

Do you see a clear advantage for using a function in this case?

Thanks,

Eshel