Subject: bug#76472: nconc should fail for dotted lists

From: "Basil L. Contovounesios" <[email-masked]>
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