GNU bug report logs -
#18837
25.0.50; `sort` -- modify function to preserve original list.
Previous Next
Reported by: Keith David Bershatsky <esq <at> lawlist.com>
Date: Sat, 25 Oct 2014 21:04:01 UTC
Severity: wishlist
Found in version 25.0.50
Done: Stefan Kangas <stefan <at> marxist.se>
Bug is archived. No further changes may be made.
Full log
Message #11 received at 18837 <at> debbugs.gnu.org (full text, mbox):
Thank you, Stefan, for taking a look at this Emacs report (#18837).
Here is my workaround:
(defun lawlist-sort (seq predicate)
(let ((disposable-list (copy-list seq)))
(sort disposable-list predicate)))
There may be situations where `copy-list` might not work, but that is beyond my present level of understanding / knowledge. I suppose that there might be some time consumption issues involved with the function `copy-list` for extremely complex lists, but none of my lists would ever get so large/complex that this would be an issue.
Thanks,
Keith
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
At Sat, 25 Oct 2014 22:44:45 -0400,
Stefan Monnier wrote:
>
> > The doc-string for the function `sort` states that `SEQ is modified by
> > side effects`; however, it does not state in what way the original
> > list gets modified or why such a feature might somehow be useful.
>
> The "usefulness" is to avoid allocating another list in the case where
> the unsorted list won't be used later on anyway.
>
>
> Stefan
This bug report was last modified 5 years and 255 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.