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

From: Stefan Kangas <[email-masked]>
Date: Sun, 23 Feb 2025 00:13:45 +0000

Eshel Yaron <[email-masked]> writes:

>> 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.

If it is different, then I agree that a different name is in probably in
order.  But see below.

>> 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?

It's slightly less typing, but also risks being more unclear, as it has
different evaluation rules.  The name `compf` is similarly fine, but to
me comes off as a little bit cryptic.

I think allowing function names to be in variables is also more general
and thus flexible, for instance supporting things like:

    (let ((fun #'some-function))
      (mapcar (compose #'not fun) some-list))

I also forgot to say thanks for digging up the old thread and this idea.
It had completely fallen off my radar.