bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


From: Philip Kaludercic
Subject: bug#62037: (proper-list-p '#1=(a #1#)) => 2. It should return nil.
Date: Sat, 18 Mar 2023 13:48:40 +0000

Alan Mackenzie <acm@muc.de> writes:

> Hello, Philip.
>
> On Sat, Mar 18, 2023 at 07:41:14 +0000, Philip Kaludercic wrote:
>> Ruijie Yu <ruijie@netyu.xyz> writes:
>
>> > Notice the distinction between these two snippets:
>
>> >     (let ((lst-1 '#1=(a #1#)))
>> >       (list lst-1 (proper-list-p lst-1)))
>> >     ;; => ((a #1) 2)
>
>> >     (let ((lst-2 '#1=(a . #1#)))
>> >       (list lst-2 (proper-list-p lst-2)))
>> >     ;; => ((a . #0) nil)
>
>> Doesn't this point resolve the issue?
>
> No, it doesn't.  A circular list is defined (Elisp manual page "Lists
> and Cons Cells") as one where "some cons cell’s CDR could point to one
> of the previous cons cells in the list".  A proper list (page
> "List-related Predicates") is one which is neither dotted nor circular.
>
> The list #1=(a . #1#) is clearly circular.  proper-list-p should return
> nil for it.

But (proper-list-p '#1=(a . #1#)) does return nil?  And (proper-list-p
'#1=(a #1#)) does return 2, 

 +---+---+   +---+---+
 | a | ----->| | | ------> nil
 +---+---+   +-|-+---+
   ^           |
    \_________/

because #1=(a #1#)) is not a circular list, the cadr only has a
reference back to a the beginning of the list, but #1=(a . #1#)) is
cyclical because as you say a cdr points back to a previous cons cell:

 +---+---+
 | a | | |
 +---+-|-+
   ^   |  
    \__/

> The purpose of proper-list-p is surely to find out in advance whether an
> algorithm one wishes to run on a list can proceed without taking special
> precautions for dottedness or circularity.  proper-list-p fails here.
>
>> Shouldn't the bug report be closed?
>
> Only once it's been fixed.
>
>> --
>> Philip Kaludercic





reply via email to

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