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

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

Why is delq the way it is?


From: xenodasein
Subject: Why is delq the way it is?
Date: Tue, 4 Oct 2022 18:46:10 +0200 (CEST)

According to it's implementation in src/fns.c:1862 (v28.2), delq
does not modify the first cons of the list it works on, it skips
the first cons but modifies the rest.

What is the reason for this?

One would need it to modify every cons including the first; when
first element needs deleting for example by doing
(setcar first-cons (car second-cons)) and
(setdcr first-cons (cdr second-cons)).
This does make references to the original second cons outdated,
whereas the current behavior is unable to modify the list at the
beginning at all, but it at least does not drop an "innocent" cons.
Instead it renders the first cons outdated to outside references.
(Hence the need to (setq lst (delq elt lst))).





reply via email to

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