all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: "Basil L. Contovounesios" <contovob@tcd.ie>
Cc: eggert@cs.ucla.edu, emacs-devel@gnu.org
Subject: Re: Predicate for true lists
Date: Fri, 06 Jul 2018 08:57:52 +0300	[thread overview]
Message-ID: <83h8lcnbxb.fsf@gnu.org> (raw)
In-Reply-To: <87r2kh9uwx.fsf@tcd.ie> (contovob@tcd.ie)

> From: "Basil L. Contovounesios" <contovob@tcd.ie>
> Date: Fri, 06 Jul 2018 01:31:26 +0300
> Cc: emacs-devel@gnu.org
> 
> I attach three patches (and a benchmark).  The first introduces the
> function proper-list-length as per your suggestion in
> https://lists.gnu.org/archive/html/emacs-devel/2018-06/msg00138.html
> (please check whether I have properly attributed you, as I am unfamiliar
> with the preferred way of doing this).
> 
> The second changes the Elisp manual to refer to "proper lists" instead
> of "true lists".
> 
> The third moves the definition of zerop in lisp/subr.el from under the
> 'List functions' heading to under the 'Basic Lisp functions' heading.
> 
> Finally, here are the updated (byte-compiled) benchmark results:
> 
>     ‘proper-list-length’
>       proper   (0.004452047000000001 0 0.0)
>       dotted   (0.005584044999999999 0 0.0)
>       circular (0.006193915          0 0.0)
>     ‘format-proper-list-p’
>       proper   (0.06397756299999999  0 0.0)
>       dotted   (0.063610087          0 0.0)
>       circular (0.09455345899999999  0 0.0)
>     ‘ert--proper-list-p’
>       proper   (0.29080201899999997  0 0.0)
>       dotted   (0.290801063          0 0.0)
>       circular (0.433813842          0 0.0)
> 
> WDYT?

Thanks, I have a few comments below.

> >From f42cb45f449dbb6c3d806398a128bc5914fdebab Mon Sep 17 00:00:00 2001
> From: "Basil L. Contovounesios" <contovob@tcd.ie>
> Date: Fri, 6 Jul 2018 00:41:11 +0300
> Subject: [PATCH 1/3] Add convenience function proper-list-length
> 
> * lisp/subr.el (proper-list-length): New function.
> Suggested by Paul Eggert <eggert@cs.ucla.edu> in
> https://lists.gnu.org/archive/html/emacs-devel/2018-06/msg00138.html.
> * doc/lispref/lists.texi (List Elements):
> * etc/NEWS: Mention it.

The "it" part here is ambiguous, because it's too far from the last
place where the function's name was mentioned.  Please state the name
of the function for better readability.

> * lisp/emacs-lisp/byte-opt.el (byte-optimize-if):
> * lisp/emacs-lisp/cl-macs.el (cl--make-usage-args):
> * lisp/org/ob-core.el (org-babel-insert-result): Use it.

Likewise.

> * lisp/emacs-lisp/ert.el (ert--proper-list-p): Remove.
> (ert--explain-equal-rec): Use proper-list-length instead.
> * lisp/format.el (format-proper-list-p): Remove.

Maybe consider mentioning that these are removed "because
SUCH-AND-SUCH replaces them in file FOO."

> +@defun proper-list-length object
> +This function returns the length of @var{object} if it is a proper
> +list, @code{nil} otherwise.  In addition to satisfying @code{listp}, a
> +proper list is neither circular nor dotted.

Proper list is defined elsewhere in the manual, so please add here a
cross-reference to that spot (I'd suggest doing that with @pxref in
parentheses at the end of the first sentence).

> +** New function 'proper-list-length'.
> +Given a proper list as argument, this function returns its length;
> +otherwise, it returns nil.  This function can thus be used as a
> +predicate for proper lists.

Do we really want this usage of the function as a predicate?  I find
this slightly unnatural, and also not future-proof enough, because you
rely on the checks 'length' does internally.  If the internals of
'length' change one day, this predicate usage will collapse like a
house of cards.  Would it make more sense to have a separate
predicate?

> +(defun proper-list-length (object)
> +  "Return OBJECT's length if it is a proper list, nil otherwise.
> +A proper list is neither circular nor dotted (i.e., its last cdr
> +is nil)."

But if we do want to use this as a predicate, then the doc string
should say so.

> * doc/lispref/lists.texi (Cons Cells, Building Lists):
> * doc/lispref/sequences.texi (Vector Functions): Do it.

Please put the full description in the log entry.  "Do it" refers to
what the header says, I presume, but I at least am used to ignoring
the headers and reading the entries, because they are generally more
informative (due to space constraints on the header).

> +@cindex proper list
>  @cindex true list
>    Also by convention, the @sc{cdr} of the last cons cell in a list is
>  @code{nil}.  We call such a @code{nil}-terminated structure a
> -@dfn{true list}.  In Emacs Lisp, the symbol @code{nil} is both a
> +@dfn{proper list}.  In Emacs Lisp, the symbol @code{nil} is both a

We still have "true list" in the index (and rightly so), so I think
the new text should say, perhaps in parens or in a footnote, that such
lists are also known as "true lists".  Imagine a reader who follows
the "true list" index entry and gets placed on this text -- they will
be confused to not see "true list" mentioned anywhere.  Besides, that
term is in wide usage elsewhere.

Thanks again for working on this.



  reply	other threads:[~2018-07-06  5:57 UTC|newest]

Thread overview: 100+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-16 19:34 Predicate for true lists Basil L. Contovounesios
2018-06-04 12:12 ` Basil L. Contovounesios
2018-06-04 14:08   ` Stefan Monnier
2018-06-04 14:46     ` Basil L. Contovounesios
2018-06-04 15:31       ` Drew Adams
2018-06-04 16:14         ` Basil L. Contovounesios
2018-06-04 16:38           ` Drew Adams
2018-06-04 16:57             ` Stefan Monnier
2018-06-05  1:23   ` Paul Eggert
2018-06-05  2:57     ` Drew Adams
2018-06-05  3:08       ` Drew Adams
2018-06-05  3:12         ` Drew Adams
2018-06-05  3:25       ` Drew Adams
2018-06-05 15:05     ` Basil L. Contovounesios
2018-06-06  7:42       ` Paul Eggert
2018-06-06  9:40         ` Van L
2018-06-06 13:44           ` Stefan Monnier
2018-06-06 17:40             ` Stefan Monnier
2018-06-07  7:03             ` Van L
2018-07-05 22:31         ` Basil L. Contovounesios
2018-07-06  5:57           ` Eli Zaretskii [this message]
2018-07-06 17:16             ` Drew Adams
2018-07-06 17:38               ` Eli Zaretskii
     [not found]               ` <<83601sl0wo.fsf@gnu.org>
2018-07-06 18:00                 ` Drew Adams
2018-07-07  6:54                   ` Eli Zaretskii
     [not found]               ` <<<83601sl0wo.fsf@gnu.org>
     [not found]                 ` <<95fda70b-5893-4788-83c5-a0bb5d708304@default>
     [not found]                   ` <<8336wvleml.fsf@gnu.org>
2018-07-07 14:42                     ` Drew Adams
2018-07-06 18:04             ` Paul Eggert
2018-07-07  6:58               ` Eli Zaretskii
2018-07-07  7:20                 ` martin rudalics
2018-07-07  8:41                 ` Paul Eggert
2018-07-07 10:04                   ` Eli Zaretskii
2018-07-07 15:04                     ` Basil L. Contovounesios
2018-07-07 16:12                       ` Eli Zaretskii
2018-07-07 16:52                         ` Basil L. Contovounesios
2018-07-07 17:07                           ` Eli Zaretskii
2018-07-07 17:14                             ` Paul Eggert
2018-07-07 17:34                               ` Eli Zaretskii
2018-07-08  0:15                               ` Drew Adams
2018-07-08  4:48                                 ` Paul Eggert
2018-07-08 15:15                                   ` Drew Adams
2018-07-08 16:00                                     ` Paul Eggert
2018-07-08 17:42                                       ` Drew Adams
2018-07-08 17:47                                         ` Paul Eggert
2018-07-07 17:06                     ` Basil L. Contovounesios
2018-07-09 19:25             ` Basil L. Contovounesios
2018-07-09 19:40               ` Basil L. Contovounesios
2018-07-10  2:02                 ` Paul Eggert
2018-07-10  5:46                   ` Basil L. Contovounesios
2018-07-11  3:02                     ` Paul Eggert
2018-07-11  6:27                       ` Basil L. Contovounesios
2018-07-15 22:55                         ` Wilfred Hughes
2018-07-16  1:37                           ` Paul Eggert
2018-07-11 14:01                       ` [Emacs-diffs] master babe0d4: Rearrange definition of zerop in subr.el Karl Fogel
2018-07-11 17:12                         ` Basil L. Contovounesios
2018-07-11 17:33                           ` Paul Eggert
2018-07-12 15:34                             ` Basil L. Contovounesios
2018-07-12 15:43                               ` Basil L. Contovounesios
2019-04-09 12:51                       ` Predicate for true lists Basil L. Contovounesios
2019-04-09 15:33                         ` Stefan Monnier
2019-04-09 16:20                           ` Basil L. Contovounesios
2019-04-09 16:32                             ` Stefan Monnier
2019-04-09 16:54                               ` Daniel Colascione
2019-04-09 17:27                                 ` Basil L. Contovounesios
2019-04-09 17:27                               ` Basil L. Contovounesios
2019-04-09 20:08                               ` Unused value of error-free function warning (was: Predicate for true lists) Basil L. Contovounesios
2019-04-09 20:40                                 ` Unused value of error-free function warning Stefan Monnier
2019-04-09 20:12                           ` Predicate for true lists Basil L. Contovounesios
2019-04-09 20:41                             ` Stefan Monnier
2019-04-10  2:32                             ` Eli Zaretskii
2019-04-10 14:16                               ` Alex Branham
2019-04-10 14:34                                 ` Basil L. Contovounesios
2019-04-10 15:01                                   ` Drew Adams
2019-04-10 15:45                                     ` Basil L. Contovounesios
2019-04-10 16:04                                       ` Eli Zaretskii
2019-04-17 17:56                                       ` Basil L. Contovounesios
2019-04-17 18:11                                         ` Stefan Monnier
2019-04-21 21:42                                           ` Basil L. Contovounesios
2019-04-17 18:55                                         ` Drew Adams
2019-04-21 21:24                                           ` Basil L. Contovounesios
2019-04-22  0:03                                             ` Drew Adams
2019-04-22  1:12                                               ` Michael Heerdegen
2019-04-22  9:39                                                 ` Drew Adams
2019-04-18 14:37                                         ` Eli Zaretskii
2019-04-21 18:30                                           ` Basil L. Contovounesios
2019-04-21 19:39                                             ` Eli Zaretskii
2019-04-21 21:37                                               ` Basil L. Contovounesios
2019-04-22  0:06                                                 ` Drew Adams
2019-04-22  7:49                                                 ` Eli Zaretskii
2019-04-22 12:59                                                   ` Basil L. Contovounesios
2019-04-22 13:12                                                     ` Eli Zaretskii
2019-04-22 15:19                                                       ` Basil L. Contovounesios
2019-04-21 19:41                                             ` Eli Zaretskii
2019-04-21 21:41                                               ` Basil L. Contovounesios
2019-04-22  6:39                                                 ` Eli Zaretskii
2019-04-22 12:58                                                   ` Basil L. Contovounesios
2018-07-06 17:00           ` Drew Adams
2018-07-06 17:20             ` Paul Eggert
2018-07-06 17:33             ` Eli Zaretskii
2018-07-08 22:38             ` Basil L. Contovounesios
2018-07-06 17:30           ` Paul Eggert
     [not found] <<<87fu3vdjjk.fsf@tcd.ie>
     [not found] <<87fu3vdjjk.fsf@tcd.ie>

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=83h8lcnbxb.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=contovob@tcd.ie \
    --cc=eggert@cs.ucla.edu \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.