[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: member inconsistency?
From: |
Stephen Berman |
Subject: |
Re: member inconsistency? |
Date: |
Thu, 28 Jan 2016 18:30:04 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) |
On Thu, 28 Jan 2016 17:48:29 +0200 Eli Zaretskii <address@hidden> wrote:
>> From: Stephen Berman <address@hidden>
>> Date: Thu, 28 Jan 2016 11:25:33 +0100
>> Cc: Philipp Stephani <address@hidden>,
>> Nicolas Goaziou <address@hidden>, address@hidden
>>
>> 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
- member inconsistency?, Nicolas Goaziou, 2016/01/28
- Re: member inconsistency?, Johan Bockgård, 2016/01/28
- Re: member inconsistency?, Stephen Berman, 2016/01/28
- Re: member inconsistency?, Andreas Schwab, 2016/01/29
- Re: member inconsistency?, Stephen Berman, 2016/01/29
- Re: member inconsistency?, Eli Zaretskii, 2016/01/29
- Re: member inconsistency?, John Wiegley, 2016/01/29