GNU bug report logs - #76242
[PATCH] Clarify that mapconcat's FUNCTION can return nil

Previous Next

Package: emacs;

Reported by: Hong Xu <hong <at> topbug.net>

Date: Wed, 12 Feb 2025 22:29:01 UTC

Severity: wishlist

Tags: patch

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 76242 in the body.
You can then email your comments to 76242 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#76242; Package emacs. (Wed, 12 Feb 2025 22:29:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Hong Xu <hong <at> topbug.net>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Wed, 12 Feb 2025 22:29:02 GMT) Full text and rfc822 format available.

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

From: Hong Xu <hong <at> topbug.net>
To: bug-gnu-emacs <at> gnu.org
Cc: Hong Xu <hong <at> topbug.net>
Subject: [PATCH] Clarify that mapconcat's FUNCTION can return nil
Date: Wed, 12 Feb 2025 14:27:03 -0800
* src/fns.c (Fmapconcat): Explain that FUNCTION can return nil.
---
 src/fns.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/fns.c b/src/fns.c
index bee44b222c5e..f02a1b6838da 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -3400,9 +3400,11 @@ SEQUENCE may be a list, a vector, a bool-vector, or a string.
 Optional argument SEPARATOR must be a string, a vector, or a list of
 characters; nil stands for the empty string.
 
-FUNCTION must be a function of one argument, and must return a value
-  that is a sequence of characters: either a string, or a vector or
-  list of numbers that are valid character codepoints.  */)
+ FUNCTION must be a function of one argument, and must return either:
+
+   nil, which is treated as an empty string, or
+   a value that is a sequence of characters, which is either a string,
+   or a vector or list of numbers that are valid character codepoints. */)
   (Lisp_Object function, Lisp_Object sequence, Lisp_Object separator)
 {
   USE_SAFE_ALLOCA;
-- 
2.48.1





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#76242; Package emacs. (Wed, 12 Feb 2025 22:32:01 GMT) Full text and rfc822 format available.

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

From: Hong Xu <hong <at> topbug.net>
To: 76242 <at> debbugs.gnu.org
Subject: Re: [PATCH] Clarify that mapconcat's FUNCTION can return nil
Date: Wed, 12 Feb 2025 14:31:31 -0800
[Message part 1 (text/plain, inline)]
On 2025-02-12 Wed 14:27 GMT-08, Hong Xu <hong <at> topbug.net> wrote:

> * src/fns.c (Fmapconcat): Explain that FUNCTION can return nil.
> ---
>  src/fns.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/src/fns.c b/src/fns.c
> index bee44b222c5e..f02a1b6838da 100644
> --- a/src/fns.c
> +++ b/src/fns.c
> @@ -3400,9 +3400,11 @@ SEQUENCE may be a list, a vector, a bool-vector, or a string.
>  Optional argument SEPARATOR must be a string, a vector, or a list of
>  characters; nil stands for the empty string.
>  
> -FUNCTION must be a function of one argument, and must return a value
> + FUNCTION must be a function of one argument, and must return either:

For some reason there is an extra space here. I've corrected this with
the attached patch.

[v2-0001-Clarify-that-mapconcat-s-FUNCTION-can-return-nil.patch (text/x-patch, inline)]
From 42b5c39abd1765efc286178d041c57623d722d0d Mon Sep 17 00:00:00 2001
From: Hong Xu <hong <at> topbug.net>
Date: Wed, 12 Feb 2025 14:25:34 -0800
Subject: [PATCH v2] Clarify that mapconcat's FUNCTION can return nil

* src/fns.c (Fmapconcat): Explain that FUNCTION can return nil.
---
 src/fns.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/fns.c b/src/fns.c
index bee44b222c5e..fc7039c1592b 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -3400,9 +3400,11 @@ SEQUENCE may be a list, a vector, a bool-vector, or a string.
 Optional argument SEPARATOR must be a string, a vector, or a list of
 characters; nil stands for the empty string.
 
-FUNCTION must be a function of one argument, and must return a value
-  that is a sequence of characters: either a string, or a vector or
-  list of numbers that are valid character codepoints.  */)
+FUNCTION must be a function of one argument, and must return either:
+
+  nil, which is treated as an empty string, or
+  a value that is a sequence of characters, which is either a string,
+  or a vector or list of numbers that are valid character codepoints. */)
   (Lisp_Object function, Lisp_Object sequence, Lisp_Object separator)
 {
   USE_SAFE_ALLOCA;
-- 
2.48.1

[Message part 3 (text/plain, inline)]
-- 
Hong

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#76242; Package emacs. (Thu, 13 Feb 2025 01:27:01 GMT) Full text and rfc822 format available.

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

From: Michael Heerdegen <michael_heerdegen <at> web.de>
To: Hong Xu via "Bug reports for GNU Emacs, the Swiss army knife of text
 editors" <bug-gnu-emacs <at> gnu.org>
Cc: 76242 <at> debbugs.gnu.org, Hong Xu <hong <at> topbug.net>
Subject: Re: bug#76242: [PATCH] Clarify that mapconcat's FUNCTION can return
 nil
Date: Thu, 13 Feb 2025 02:27:52 +0100
Hong Xu via "Bug reports for GNU Emacs, the Swiss army knife of text
editors" <bug-gnu-emacs <at> gnu.org> writes:

> -FUNCTION must be a function of one argument, and must return a value
> -  that is a sequence of characters: either a string, or a vector or
> -  list of numbers that are valid character codepoints.  */)
> + FUNCTION must be a function of one argument, and must return either:
> +
> +   nil, which is treated as an empty string, or
> +   a value that is a sequence of characters, which is either a string,
> +   or a vector or list of numbers that are valid character codepoints. */)

I don't understand the rationale.  Isn't nil just one case of an empty
sequence of characters?  Why describe it specially?


Michael.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#76242; Package emacs. (Thu, 13 Feb 2025 01:27:02 GMT) Full text and rfc822 format available.

Severity set to 'wishlist' from 'normal' Request was from Stefan Kangas <stefankangas <at> gmail.com> to control <at> debbugs.gnu.org. (Thu, 13 Feb 2025 06:56:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#76242; Package emacs. (Thu, 13 Feb 2025 07:58:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Michael Heerdegen <michael_heerdegen <at> web.de>
Cc: 76242 <at> debbugs.gnu.org, hong <at> topbug.net
Subject: Re: bug#76242: [PATCH] Clarify that mapconcat's FUNCTION can return
 nil
Date: Thu, 13 Feb 2025 09:57:05 +0200
> Cc: hong <at> topbug.net
> Date: Thu, 13 Feb 2025 02:27:52 +0100
> From:  Michael Heerdegen via "Bug reports for GNU Emacs,
>  the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org>
> 
> Hong Xu via "Bug reports for GNU Emacs, the Swiss army knife of text
> editors" <bug-gnu-emacs <at> gnu.org> writes:
> 
> > -FUNCTION must be a function of one argument, and must return a value
> > -  that is a sequence of characters: either a string, or a vector or
> > -  list of numbers that are valid character codepoints.  */)
> > + FUNCTION must be a function of one argument, and must return either:
> > +
> > +   nil, which is treated as an empty string, or
> > +   a value that is a sequence of characters, which is either a string,
> > +   or a vector or list of numbers that are valid character codepoints. */)
> 
> I don't understand the rationale.  Isn't nil just one case of an empty
> sequence of characters?  Why describe it specially?

How about the below instead:

  FUNCTION must be a function of one argument, and must return a value
    that is a sequence of characters: either a string, or a vector or
    list of numbers that are valid character codepoints; nil is treated
    as an empty string.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#76242; Package emacs. (Thu, 13 Feb 2025 08:29:01 GMT) Full text and rfc822 format available.

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

From: Hong Xu <hong <at> topbug.net>
To: Eli Zaretskii <eliz <at> gnu.org>, Michael Heerdegen <michael_heerdegen <at> web.de>
Cc: 76242 <at> debbugs.gnu.org
Subject: Re: bug#76242: [PATCH] Clarify that mapconcat's FUNCTION can return nil
Date: Thu, 13 Feb 2025 00:27:45 -0800
On February 12, 2025 11:57:05 PM PST, Eli Zaretskii <eliz <at> gnu.org> wrote:
>> Cc: hong <at> topbug.net
>> Date: Thu, 13 Feb 2025 02:27:52 +0100
>> From:  Michael Heerdegen via "Bug reports for GNU Emacs,
>>  the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org>
>> 
>> Hong Xu via "Bug reports for GNU Emacs, the Swiss army knife of text
>> editors" <bug-gnu-emacs <at> gnu.org> writes:
>> 
>> > -FUNCTION must be a function of one argument, and must return a value
>> > -  that is a sequence of characters: either a string, or a vector or
>> > -  list of numbers that are valid character codepoints.  */)
>> > + FUNCTION must be a function of one argument, and must return either:
>> > +
>> > +   nil, which is treated as an empty string, or
>> > +   a value that is a sequence of characters, which is either a string,
>> > +   or a vector or list of numbers that are valid character codepoints. */)
>> 
>> I don't understand the rationale.  Isn't nil just one case of an empty
>> sequence of characters?  Why describe it specially?
>
>How about the below instead:
>
>  FUNCTION must be a function of one argument, and must return a value
>    that is a sequence of characters: either a string, or a vector or
>    list of numbers that are valid character codepoints; nil is treated
>    as an empty string.

I agree, this is better.


Hong




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#76242; Package emacs. (Thu, 13 Feb 2025 08:30:01 GMT) Full text and rfc822 format available.

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

From: Stefan Kangas <stefankangas <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>, Michael Heerdegen <michael_heerdegen <at> web.de>
Cc: 76242 <at> debbugs.gnu.org, hong <at> topbug.net
Subject: Re: bug#76242: [PATCH] Clarify that mapconcat's FUNCTION can return
 nil
Date: Thu, 13 Feb 2025 00:29:27 -0800
Eli Zaretskii <eliz <at> gnu.org> writes:

> How about the below instead:
>
>   FUNCTION must be a function of one argument, and must return a value
>     that is a sequence of characters: either a string, or a vector or
>     list of numbers that are valid character codepoints; nil is treated
>     as an empty string.

LGTM.




Reply sent to Eli Zaretskii <eliz <at> gnu.org>:
You have taken responsibility. (Thu, 13 Feb 2025 09:06:03 GMT) Full text and rfc822 format available.

Notification sent to Hong Xu <hong <at> topbug.net>:
bug acknowledged by developer. (Thu, 13 Feb 2025 09:06:03 GMT) Full text and rfc822 format available.

Message #30 received at 76242-done <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Hong Xu <hong <at> topbug.net>
Cc: michael_heerdegen <at> web.de, 76242-done <at> debbugs.gnu.org
Subject: Re: bug#76242: [PATCH] Clarify that mapconcat's FUNCTION can return
 nil
Date: Thu, 13 Feb 2025 11:04:34 +0200
> Date: Thu, 13 Feb 2025 00:27:45 -0800
> From: Hong Xu <hong <at> topbug.net>
> CC: 76242 <at> debbugs.gnu.org
> 
> On February 12, 2025 11:57:05 PM PST, Eli Zaretskii <eliz <at> gnu.org> wrote:
> >> Cc: hong <at> topbug.net
> >> Date: Thu, 13 Feb 2025 02:27:52 +0100
> >> From:  Michael Heerdegen via "Bug reports for GNU Emacs,
> >>  the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org>
> >> 
> >> Hong Xu via "Bug reports for GNU Emacs, the Swiss army knife of text
> >> editors" <bug-gnu-emacs <at> gnu.org> writes:
> >> 
> >> > -FUNCTION must be a function of one argument, and must return a value
> >> > -  that is a sequence of characters: either a string, or a vector or
> >> > -  list of numbers that are valid character codepoints.  */)
> >> > + FUNCTION must be a function of one argument, and must return either:
> >> > +
> >> > +   nil, which is treated as an empty string, or
> >> > +   a value that is a sequence of characters, which is either a string,
> >> > +   or a vector or list of numbers that are valid character codepoints. */)
> >> 
> >> I don't understand the rationale.  Isn't nil just one case of an empty
> >> sequence of characters?  Why describe it specially?
> >
> >How about the below instead:
> >
> >  FUNCTION must be a function of one argument, and must return a value
> >    that is a sequence of characters: either a string, or a vector or
> >    list of numbers that are valid character codepoints; nil is treated
> >    as an empty string.
> 
> I agree, this is better.

> From: Stefan Kangas <stefankangas <at> gmail.com>
> Date: Thu, 13 Feb 2025 00:29:27 -0800
> Cc: 76242 <at> debbugs.gnu.org, hong <at> topbug.net
> 
> Eli Zaretskii <eliz <at> gnu.org> writes:
> 
> > How about the below instead:
> >
> >   FUNCTION must be a function of one argument, and must return a value
> >     that is a sequence of characters: either a string, or a vector or
> >     list of numbers that are valid character codepoints; nil is treated
> >     as an empty string.
> 
> LGTM.

Thanks, installed on the emacs-30 release branch, and closing the bug.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 13 Mar 2025 11:24:17 GMT) Full text and rfc822 format available.

This bug report was last modified 99 days ago.

Previous Next


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