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

Previous Next

Package: emacs;

Reported by: Alan Mackenzie <acm <at> muc.de>

Date: Tue, 7 Mar 2023 17:31:01 UTC

Severity: normal

Full log


View this message in rfc822 format

From: "Basil L. Contovounesios" <basil <at> contovou.net>
To: Alan Mackenzie <acm <at> muc.de>
Cc: Ruijie Yu <ruijie <at> netyu.xyz>, 62037 <at> debbugs.gnu.org, Philip Kaludercic <philipk <at> posteo.net>
Subject: bug#62037: (proper-list-p '#1=(a #1#)) => 2.  It should return nil.
Date: Sun, 26 Jan 2025 13:40:25 +0100
Alan Mackenzie [2023-03-18 08:29 +0000] wrote:

> The list #1=(a . #1#) is clearly circular.  proper-list-p should return
> nil for it.

It does.

But the subject of the bug report is about #1=(a #1#) not #1=(a . #1#).

> 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.

proper-list-p checks along the list's cdrs.

Detecting the circularity in #1=(a #1#) requires checking along the cars
as well.  To me that implies a (more expensive) proper-tree-p (or
similar) rather than proper-list-p, for the same reason that 'length'
returns the same result as proper-list-p for #1=(a 1#).

Would it help if the documentation of proper-list-p just mentioned the
phrase 'along the cdrs', in the same way that copy-tree does?

Thanks,
-- 
Basil




This bug report was last modified 138 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.