unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#36418: 26.2.90; mapconcat "SEPARATOR must be a string." is incorrect
@ 2019-06-28 13:23 Xu Chunyang
  2019-07-06  4:17 ` Stefan Kangas
  0 siblings, 1 reply; 3+ messages in thread
From: Xu Chunyang @ 2019-06-28 13:23 UTC (permalink / raw)
  To: 36418

C-h f mapconcat says

> SEPARATOR must be a string.

but nil works fine

    (mapconcat #'identity '("a" "b") nil)
    ;; => "ab"

and `string-join` relies on this fact (by the way, string-join's
docstring doesn't explain the case when separator is omitted or nil)

    (defsubst string-join (strings &optional separator)
      "Join all STRINGS using SEPARATOR."
      (mapconcat 'identity strings separator))

C-h S mapconcat says

> SEPARATOR, which also must be a string, or a vector or list of
> characters.

C-h f concat says

> Each argument may be a string or a list or vector of characters (integers).





^ permalink raw reply	[flat|nested] 3+ messages in thread

* bug#36418: 26.2.90; mapconcat "SEPARATOR must be a string." is incorrect
  2019-06-28 13:23 bug#36418: 26.2.90; mapconcat "SEPARATOR must be a string." is incorrect Xu Chunyang
@ 2019-07-06  4:17 ` Stefan Kangas
  2019-07-06  7:32   ` Eli Zaretskii
  0 siblings, 1 reply; 3+ messages in thread
From: Stefan Kangas @ 2019-07-06  4:17 UTC (permalink / raw)
  To: Xu Chunyang; +Cc: 36418

Xu Chunyang <mail@xuchunyang.me> writes:

> C-h f mapconcat says
>
>> SEPARATOR must be a string.
>
> but nil works fine
>
>     (mapconcat #'identity '("a" "b") nil)
>     ;; => "ab"

This seems to have been added in commit aecbbd57, which fixes
Bug#35710:

   https://debbugs.gnu.org/cgi/bugreport.cgi?bug=35710

Perhaps Eli would want to weigh in on this?

> and `string-join` relies on this fact (by the way, string-join's
> docstring doesn't explain the case when separator is omitted or nil)
>
>     (defsubst string-join (strings &optional separator)
>       "Join all STRINGS using SEPARATOR."
>       (mapconcat 'identity strings separator))

This could be expanded, in my opinion.

> C-h S mapconcat says
>
>> SEPARATOR, which also must be a string, or a vector or list of
>> characters.
>
> C-h f concat says
>
>> Each argument may be a string or a list or vector of characters (integers).

In other words, since SEPARATOR can be a "list of characters", it
follows that it can also be nil (which is equivalent to the empty list).

Thanks,
Stefan Kangas





^ permalink raw reply	[flat|nested] 3+ messages in thread

* bug#36418: 26.2.90; mapconcat "SEPARATOR must be a string." is incorrect
  2019-07-06  4:17 ` Stefan Kangas
@ 2019-07-06  7:32   ` Eli Zaretskii
  0 siblings, 0 replies; 3+ messages in thread
From: Eli Zaretskii @ 2019-07-06  7:32 UTC (permalink / raw)
  To: Stefan Kangas; +Cc: 36418-done, mail

> From: Stefan Kangas <stefan@marxist.se>
> Date: Sat, 6 Jul 2019 06:17:08 +0200
> Cc: 36418@debbugs.gnu.org
> 
> > C-h S mapconcat says
> >
> >> SEPARATOR, which also must be a string, or a vector or list of
> >> characters.
> >
> > C-h f concat says
> >
> >> Each argument may be a string or a list or vector of characters (integers).
> 
> In other words, since SEPARATOR can be a "list of characters", it
> follows that it can also be nil (which is equivalent to the empty list).

Right, I fixed the doc string.





^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-07-06  7:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-06-28 13:23 bug#36418: 26.2.90; mapconcat "SEPARATOR must be a string." is incorrect Xu Chunyang
2019-07-06  4:17 ` Stefan Kangas
2019-07-06  7:32   ` Eli Zaretskii

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).