Subject: bug#62037: (proper-list-p '#1=(a #1#)) => 2. It should return nil.

From: Ruijie Yu <[email-masked]>
Date: Fri, 31 Mar 2023 15:29:13 +0800

Philip Kaludercic <[email-masked]> writes:
>> So, it all boils down to the fact that the current documentation is
>> lacking and/or ambiguous, in terms of "the purpose of `proper-list-p'",
>> as well as the two definitions of the adjective "circular", which are
>> not interchangeable in different contexts.
>
> It might be lacking, but I don't think the explanation is ambiguous.
> "its last cdr is nil" might not be awfully formal, but it does describe
> the problem.

I agree.  However, I would reorganize it slightly to make "cdr being
nil" stand out more.  See this snippet for `proper-list-p' docstring,
and note that I explicitly mentioned circular _list_ to avoid confusion.

--8<---------------cut here---------------start------------->8---
- A proper list is neither circular nor dotted (i.e., its last cdr is nil).
+ A proper list is a list whose last cdr is nil (i.e., neither a circular list nor dotted list).
--8<---------------cut here---------------end--------------->8---

Again, I find it problematic that there are two related definitions of
"circular", and the first search result for "circular" under Elisp info
manual is (info "(elisp) Circular Objects"), which is not what is
intended for `proper-list-p'.  This causes problems in understanding the
intended behavior of this function, manifested via this bug.

-- 
Best,

RY