all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Why is delq the way it is?
@ 2022-10-04 16:46 xenodasein--- via Users list for the GNU Emacs text editor
  0 siblings, 0 replies; only message in thread
From: xenodasein--- via Users list for the GNU Emacs text editor @ 2022-10-04 16:46 UTC (permalink / raw)
  To: Help Gnu Emacs

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





^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-10-04 16:46 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-04 16:46 Why is delq the way it is? xenodasein--- via Users list for the GNU Emacs text editor

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.