GNU bug report logs - #78656
[PATCH] Add new reduction primitives `fold-left' and `fold-right'

Previous Next

Package: emacs;

Reported by: Zach Shaftel <zach <at> shaf.tel>

Date: Sun, 1 Jun 2025 02:36:06 UTC

Severity: normal

Tags: patch

Full log


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

From: Michael Heerdegen <michael_heerdegen <at> web.de>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 78656 <at> debbugs.gnu.org, Zach Shaftel <zach <at> shaf.tel>
Subject: Re: bug#78656: [PATCH] Add new reduction primitives `fold-left' and
 `fold-right'
Date: Tue, 03 Jun 2025 01:09:32 +0200
Eli Zaretskii <eliz <at> gnu.org> writes:

> On balance, I'd prefer to have a new function in seq.el rather than
> another primitive in C.  Since we didn't need this function until now,
> it is reasonable to assume it is not going to be a hot spot in any
> program, so an implementation in C is not really required.

Since this would just add an implicit `seq-reverse' call, this doesn't
sound convincing either.  `cl-reduce' is able to reduce :from-end.  If
at all, then adding a new argument to `seq-reduce' that causes reducing
from the end sounds more sensible to me.

@Zach: I really can feel your desire to have a primitive but part of the
story is also that Emacs Lisp is not that purely functional language
that some of us wish, since it's a lot more iteration oriented than
other Lisps - recursion depth is horribly limited, for example.  Trying
to use a purely functional style in Elisp doesn't work well.

So, in Elisp we are having most of these things in seq.el instead of the
core, and I think it's appropriate.  Especially folding is an operation
that is not used that often in Elisp.


Michael.




This bug report was last modified 13 days ago.

Previous Next


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