GNU bug report logs -
#78656
[PATCH] Add new reduction primitives `fold-left' and `fold-right'
Previous Next
Full log
View this message in rfc822 format
> From: Zach Shaftel <zach <at> shaf.tel>
> Cc: 78656 <at> debbugs.gnu.org
> Date: Sun, 01 Jun 2025 13:38:41 -0400
>
> Eli Zaretskii <eliz <at> gnu.org> writes:
>
> > As to fold-right, couldn't we just add another function to seq.el? Or
> > are there good reasons to have these implemented in C?
>
> the main reason was for `fold-right' to use a C array to temporarily
> hold list elements, instead of needing to `vconcat' or `reverse' the
> list first. that's not hugely problematic, and i think an elisp
> implementation would also be fine.
>
> more generally, my thinking is that reduction is a core operator in
> functional programming, which has become a dominant style in the elisp
> ecosystem, so it would be nice to have a speed/space efficient
> implementation. i assumed that's why `mapcar' is in C.
>
> but, ultimately i knew this might not be a good fit. i was just curious,
> and also wanted to see how well i understood the C internals.
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.
This bug report was last modified 50 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.