[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 22:57:49 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) |
On Thu, 28 Jan 2016 20:35:40 +0200 Eli Zaretskii <address@hidden> wrote:
>> From: Stephen Berman <address@hidden>
>> Cc: address@hidden, address@hidden, address@hidden, address@hidden
>> Date: Thu, 28 Jan 2016 18:30:04 +0100
>>
>> 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?
>
> Before the loop sounds slightly less obscure to me.
With just
CHECK_LIST_CONS (list, list);
before the loop, the build fails with "wrong-type-argument: nil, listp"
in subr.el. With
if (!NILP (list))
CHECK_LIST_CONS (list, list);
before the loop, the build succeeds (same with Fmemql). But isn't this
then effectively the same thing as having CHECK_LIST (list) before the
loop? With that, the build also succeeds and I didn't see any problems
with calls to member. I'm confused.
Two other things I don't get: (1) I wondered why Fmember can't be
defined with a while (1) loop analogously to Fmemq, Fassq und Fassoc,
but when I tried that the build failed at
temacs --batch --load loadup bootstrap
even though I added a !NILP (list) check.
(2) Why are there three occurrences in a row of these lines in Fmemq
(and similar repetitions in Fassq and Fassoc)?
if (!CONSP (list) || EQ (XCAR (list), elt))
break;
list = XCDR (list);
I commented out two of the occurrences and built emacs successfully and
all my tests of memq went as expected. So why the repetitions?
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
- Re: member inconsistency?, Richard Stallman, 2016/01/29