[emacs-w3m:13203] Re: reversed and copied lists

Vladimir Sedach <[email protected]>
Newsgroups gmane.emacs.w3m
Message-ID <[email protected]>
> What seems to me more sensible is:
…

That version, with the copy-sequence, is much better.

> What's bothering me is the documentation for function copy-sequence
> which seems unclear to me whether it really is creating a copy or just
> another symbol pointing to the same objects.

COPY-SEQUENCE is a function, so it never sees the place
(symbol-value, etc.) where the list lives. The note is about
COPY-SEQUENCE creating a shallow copy.

BUTLAST creates a new list, so COPY-SEQUENCE is redundant there. LAST
just gives you the tail of the list without copying anything, so
COPY-SEQUENCE is needed.

In general I think all uses of NREVERSE, RPLACA, SORT, etc.
list-modifying functions, and all list traversals that depend on
sharing list structure (by SETQ-ing the cdr of a list into someplace
else), should be treated as having bugs in emacs-w3m. This was the
issue I found with W3M-GENERATE-NEW-BUFFER in February 2018, and it
looks like there is a similar issue when it comes to saving sessions
(I have not spent any time debugging this yet, but my session file
definitely shows the bug).

So this is a very good change.

I think later it would be nice to replace uses of W3M-SUB-LIST with
calls to LAST/BUTLAST and get rid of it. That would make the code
simpler and easier to read.

Vladimir
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.