unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Stephen Berman <stephen.berman@gmx.net>
To: Eli Zaretskii <eliz@gnu.org>
Cc: schwab@suse.de, p.stephani2@gmail.com, mail@nicolasgoaziou.fr,
	emacs-devel@gnu.org
Subject: Re: member inconsistency?
Date: Thu, 28 Jan 2016 18:30:04 +0100	[thread overview]
Message-ID: <87wpqt8vdv.fsf@gmx.net> (raw)
In-Reply-To: <83bn85zovm.fsf@gnu.org> (Eli Zaretskii's message of "Thu, 28 Jan 2016 17:48:29 +0200")

On Thu, 28 Jan 2016 17:48:29 +0200 Eli Zaretskii <eliz@gnu.org> wrote:

>> From: Stephen Berman <stephen.berman@gmx.net>
>> Date: Thu, 28 Jan 2016 11:25:33 +0100
>> Cc: Philipp Stephani <p.stephani2@gmail.com>,
>> 	Nicolas Goaziou <mail@nicolasgoaziou.fr>, emacs-devel@gnu.org
>> 
>> In contrast, `member' (and `memql' in the float case) has no check
>> and also uses a for-loop with the condition CONSP (tail), and when
>> this fails, the function just returns Qnil.  Adding CHECK_LIST
>> (list) before the for-loop makes (member 'a 'b) signal an error.
>
> I'd say CHECK_LIST_CONS, not CHECK_LIST, don't you agree?

To be honest, I overlooked that CHECK_LIST_CONS is inside the for-loop.
But it seems a bit ugly to have the same check before the loop and
inside it as well.  How about the following:

diff --git a/src/fns.c b/src/fns.c
index 86ad333..17c4a75 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -1349,7 +1349,7 @@ The value is actually the tail of LIST whose car is ELT.  */)
   (register Lisp_Object elt, Lisp_Object list)
 {
   register Lisp_Object tail;
-  for (tail = list; CONSP (tail); tail = XCDR (tail))
+  for (tail = list; CONSP (tail) || !NILP (tail); tail = XCDR (tail))
     {
       register Lisp_Object tem;
       CHECK_LIST_CONS (tail, list);

Or is having the check before the loop better it catches the error sooner?

Steve Berman



  reply	other threads:[~2016-01-28 17:30 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-28  8:42 member inconsistency? Nicolas Goaziou
2016-01-28  9:41 ` Philipp Stephani
2016-01-28 10:14   ` Andreas Schwab
2016-01-28 10:25     ` Stephen Berman
2016-01-28 15:48       ` Eli Zaretskii
2016-01-28 17:30         ` Stephen Berman [this message]
2016-01-28 18:35           ` Eli Zaretskii
2016-01-28 21:57             ` Stephen Berman
2016-01-28 22:18           ` Andreas Schwab
2016-01-28 22:41             ` Stephen Berman
2016-01-28 23:38       ` Johan Bockgård
2016-01-28 23:57         ` Stephen Berman
2016-01-29 10:25           ` Andreas Schwab
2016-01-29 11:20             ` Stephen Berman
2016-01-29 14:15             ` Eli Zaretskii
2016-01-29 19:17               ` John Wiegley
2016-01-29 23:58         ` Richard Stallman
2016-02-01  7:10           ` Fabrice Popineau
2016-02-01 11:04             ` Richard Stallman
2016-02-01 12:20               ` Fabrice Popineau

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=87wpqt8vdv.fsf@gmx.net \
    --to=stephen.berman@gmx.net \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=mail@nicolasgoaziou.fr \
    --cc=p.stephani2@gmail.com \
    --cc=schwab@suse.de \
    /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 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).