[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#18837: 25.0.50; `sort` -- modify function to preserve original list.
From: |
Keith David Bershatsky |
Subject: |
bug#18837: 25.0.50; `sort` -- modify function to preserve original list. |
Date: |
Sat, 25 Oct 2014 22:04:55 -0700 |
User-agent: |
/ () / () APEL/10.8 Emacs/25.0.50 (x86_64-apple-darwin10.8.0) MULE/6.0 (HANACHIRUSATO) |
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