unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Philip Kaludercic <philipk@posteo.net>
To: Alan Mackenzie <acm@muc.de>
Cc: Ruijie Yu <ruijie@netyu.xyz>, 62037@debbugs.gnu.org
Subject: bug#62037: (proper-list-p '#1=(a #1#)) => 2.  It should return nil.
Date: Sat, 18 Mar 2023 13:48:40 +0000	[thread overview]
Message-ID: <87y1nuw4p3.fsf@posteo.net> (raw)
In-Reply-To: <ZBV2TlXqrirkPBNT@ACM> (Alan Mackenzie's message of "Sat, 18 Mar 2023 08:29:02 +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	other threads:[~2023-03-18 13:48 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-07 17:29 bug#62037: (proper-list-p '#1=(a #1#)) => 2. It should return nil Alan Mackenzie
2023-03-08  4:13 ` Ruijie Yu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-03-18  7:41   ` Philip Kaludercic
2023-03-18  8:29     ` Alan Mackenzie
2023-03-18 13:48       ` Philip Kaludercic [this message]
2023-03-31  4:35         ` Ruijie Yu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-03-31  7:25           ` Philip Kaludercic
2023-03-31  7:29             ` Ruijie Yu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-03-31  7:50               ` Eli Zaretskii
2023-04-01 14:16                 ` Ruijie Yu via Bug reports for GNU Emacs, the Swiss army knife of text editors

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87y1nuw4p3.fsf@posteo.net \
    --to=philipk@posteo.net \
    --cc=62037@debbugs.gnu.org \
    --cc=acm@muc.de \
    --cc=ruijie@netyu.xyz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).