GNU bug report logs - #76472
nconc should fail for dotted lists

Previous Next

Package: emacs;

Reported by: Pip Cet <pipcet <at> protonmail.com>

Date: Fri, 21 Feb 2025 14:16:02 UTC

Severity: normal

Done: Pip Cet <pipcet <at> protonmail.com>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: "Basil L. Contovounesios" <basil <at> contovou.net>
To: Mattias Engdegård <mattias.engdegard <at> gmail.com>
Cc: Pip Cet <pipcet <at> protonmail.com>, 76472 <at> debbugs.gnu.org
Subject: bug#76472: nconc should fail for dotted lists
Date: Sat, 22 Feb 2025 11:47:45 +0100
Mattias Engdegård [2025-02-21 18:25 +0100] wrote:

>> The current behavior is: (nconc '(1 . 2) '(3 4)) => (1 3 4) 
>
> Actually that is probably intended and completely fine. It's what Common Lisp
> defines for this operation, and I don't think adding a nil check would be an
> improvement.

Not just probably intended, but explicitly called out in the Elisp
manual:

     ...
     copied.  Instead, the last CDR of each of the LISTS is changed to
     refer to the following list.  The last of the LISTS is not altered.
     ...
     However, the other arguments (all but the last) should be mutable
     lists.  They can be dotted lists, whose last CDRs are then replaced
     with the next argument:

          (nconc (cons 1 2) (cons 3 (cons 4 5)) 'z)
               ⇒ (1 3 4 . z)

-- 
Basil




This bug report was last modified 140 days ago.

Previous Next


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