[Top][All Lists]

[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 11:25:33 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux)

On Thu, 28 Jan 2016 11:14:37 +0100 Andreas Schwab <address@hidden> wrote:

> Philipp Stephani <address@hidden> writes:
>> Nicolas Goaziou <address@hidden> schrieb am Do., 28. Jan. 2016 um
>> 09:41 Uhr:
>>> Hello,
>>> The following behaviour is surprising
>>>   (assq 'a 'b)   => #ERROR
>>>   (memq 'a 'b)   => #ERROR
>>>   (assoc 'a 'b)  => #ERROR
>> For completeness, memql and assq have the same behavior.
> memql works like member if looking for a float, like memq otherwise.

The definition of `memq' calls CHECK_LIST (list) and `assq' and `assoc'
return CAR (list), and each of these signals the error in case of a
wrong type.  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.
(Instead of a for-loop, the other three use while (1), so the loop
always runs and the type checks get executed.)

Steve Berman

reply via email to

[Prev in Thread] Current Thread [Next in Thread]