unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#35710: 26.1; incomplete mapconcat description string
@ 2019-05-13  8:43 phs
  2019-05-13 12:02 ` Noam Postavsky
       [not found] ` <handler.35710.B.155773799422638.ack@debbugs.gnu.org>
  0 siblings, 2 replies; 5+ messages in thread
From: phs @ 2019-05-13  8:43 UTC (permalink / raw)
  To: 35710


In my v26.1, the description string for mapconcat is

   mapconcat is a built-in function in ‘src/fns.c’.

   (mapconcat FUNCTION SEQUENCE SEPARATOR)

   Apply FUNCTION to each element of SEQUENCE, and concat the results as
strings.
   In between each pair of results, stick in SEPARATOR.  Thus, " " as
   SEPARATOR results in spaces between the values returned by FUNCTION.
   SEQUENCE may be a list, a vector, a bool-vector, or a string.

The description does not say what is accepted for SEPARATOR, it only
gives an example.

By playing around a bit, it turns out that SEPARATOR can be a string
(obviously), a list of chars, a vector of chars, the empty bool-vector
but not any other bool-vector.

It is not clear why these possibilities are offered while some are not
(e.g., why not make SEPARATOR optional?). This is one more reason to
make the description string explicit about what is allowed.
-- 
Philippe SCHNOEBELEN,       	
"Algebraic symbols are used when you do not know what you are talking about"





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

* bug#35710: 26.1; incomplete mapconcat description string
  2019-05-13  8:43 bug#35710: 26.1; incomplete mapconcat description string phs
@ 2019-05-13 12:02 ` Noam Postavsky
  2019-05-13 14:14   ` Eli Zaretskii
       [not found] ` <handler.35710.B.155773799422638.ack@debbugs.gnu.org>
  1 sibling, 1 reply; 5+ messages in thread
From: Noam Postavsky @ 2019-05-13 12:02 UTC (permalink / raw)
  To: phs; +Cc: 35710

phs <phs@lsv.fr> writes:

> In my v26.1, the description string for mapconcat is
>
>    mapconcat is a built-in function in ‘src/fns.c’.
>
>    (mapconcat FUNCTION SEQUENCE SEPARATOR)
>
>    Apply FUNCTION to each element of SEQUENCE, and concat the results as
> strings.
>    In between each pair of results, stick in SEPARATOR.  Thus, " " as
>    SEPARATOR results in spaces between the values returned by FUNCTION.
>    SEQUENCE may be a list, a vector, a bool-vector, or a string.
>
> The description does not say what is accepted for SEPARATOR, it only
> gives an example.

It mentions concat, which is what determines what is acceptable.  I
agree it could be made more explicit though.





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

* bug#35710: 26.1; incomplete mapconcat description string
  2019-05-13 12:02 ` Noam Postavsky
@ 2019-05-13 14:14   ` Eli Zaretskii
  0 siblings, 0 replies; 5+ messages in thread
From: Eli Zaretskii @ 2019-05-13 14:14 UTC (permalink / raw)
  To: Noam Postavsky; +Cc: phs, 35710

> From: Noam Postavsky <npostavs@gmail.com>
> Date: Mon, 13 May 2019 08:02:44 -0400
> Cc: 35710@debbugs.gnu.org
> 
> >    (mapconcat FUNCTION SEQUENCE SEPARATOR)
> >
> >    Apply FUNCTION to each element of SEQUENCE, and concat the results as
> > strings.
> >    In between each pair of results, stick in SEPARATOR.  Thus, " " as
> >    SEPARATOR results in spaces between the values returned by FUNCTION.
> >    SEQUENCE may be a list, a vector, a bool-vector, or a string.
> >
> > The description does not say what is accepted for SEPARATOR, it only
> > gives an example.
> 
> It mentions concat, which is what determines what is acceptable.  I
> agree it could be made more explicit though.

The manual does spell that out, we could simply add that to the doc
string.





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

* bug#35710: Acknowledgement (26.1; incomplete mapconcat description string)
       [not found] ` <handler.35710.B.155773799422638.ack@debbugs.gnu.org>
@ 2019-05-14  8:14   ` phs
  2019-06-07 13:02     ` Eli Zaretskii
  0 siblings, 1 reply; 5+ messages in thread
From: phs @ 2019-05-14  8:14 UTC (permalink / raw)
  To: 35710

[-- Attachment #1: Type: text/plain, Size: 588 bytes --]

Thanks for the explanations, I never realized that concat was so
versatile (and I'm an emacs lover since 1983). Live and learn ...

Here is a suggested replacement for the documentation string (patch
attached). It produces

	Apply FUNCTION to each element of SEQUENCE, and concat the results as
strings.
	In between each pair of results, stick in SEPARATOR.  Thus, " " as
	SEPARATOR results in spaces between the values returned by FUNCTION.
	SEQUENCE may be a list, a vector, etc. see ‘mapcar’.
	SEPARATOR and all values returned by FUNCTION must be accepted by ‘concat’.

--phs

[-- Attachment #2: mapconcat-descr.patch --]
[-- Type: text/plain, Size: 709 bytes --]

diff --git a/src/fns.c b/src/fns.c
index c3202495da..f5e2584587 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -2668,7 +2668,8 @@ DEFUN ("mapconcat", Fmapconcat, Smapconcat, 3, 3, 0,
        doc: /* Apply FUNCTION to each element of SEQUENCE, and concat the results as strings.
 In between each pair of results, stick in SEPARATOR.  Thus, " " as
 SEPARATOR results in spaces between the values returned by FUNCTION.
-SEQUENCE may be a list, a vector, a bool-vector, or a string.  */)
+SEQUENCE may be a list, a vector, etc. see `mapcar'.
+SEPARATOR and all values returned by FUNCTION must be accepted by `concat'.  */)
   (Lisp_Object function, Lisp_Object sequence, Lisp_Object separator)
 {
   USE_SAFE_ALLOCA;

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

* bug#35710: Acknowledgement (26.1; incomplete mapconcat description string)
  2019-05-14  8:14   ` bug#35710: Acknowledgement (26.1; incomplete mapconcat description string) phs
@ 2019-06-07 13:02     ` Eli Zaretskii
  0 siblings, 0 replies; 5+ messages in thread
From: Eli Zaretskii @ 2019-06-07 13:02 UTC (permalink / raw)
  To: phs; +Cc: 35710-done

> From: phs <phs@lsv.fr>
> Date: Tue, 14 May 2019 10:14:02 +0200
> 
> Thanks for the explanations, I never realized that concat was so
> versatile (and I'm an emacs lover since 1983). Live and learn ...
> 
> Here is a suggested replacement for the documentation string (patch
> attached). It produces
> 
> 	Apply FUNCTION to each element of SEQUENCE, and concat the results as
> strings.
> 	In between each pair of results, stick in SEPARATOR.  Thus, " " as
> 	SEPARATOR results in spaces between the values returned by FUNCTION.
> 	SEQUENCE may be a list, a vector, etc. see ‘mapcar’.
> 	SEPARATOR and all values returned by FUNCTION must be accepted by ‘concat’.

Thanks, I fixed the doc string in a slightly different way.  The fix
will be in Emacs 26.3.  I'm therefore marking this bug done.





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

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

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-05-13  8:43 bug#35710: 26.1; incomplete mapconcat description string phs
2019-05-13 12:02 ` Noam Postavsky
2019-05-13 14:14   ` Eli Zaretskii
     [not found] ` <handler.35710.B.155773799422638.ack@debbugs.gnu.org>
2019-05-14  8:14   ` bug#35710: Acknowledgement (26.1; incomplete mapconcat description string) phs
2019-06-07 13:02     ` 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).