[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: reversed and copied lists
> 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