unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Daniel Schoepe <daniel@schoepe.org>
To: emacs-devel@gnu.org
Subject: Side effects of `sort'
Date: Thu, 01 Mar 2012 20:58:16 +0100	[thread overview]
Message-ID: <8762eoum93.fsf@schoepe.localhost> (raw)

[-- Attachment #1: Type: text/plain, Size: 884 bytes --]

Hi,

according to describe-function, `sort' modifies its input list, but not
in any way that the programmer can rely on. (For example, '(2 1 3)
becomes '(2 3)). I assume the precise thing that ends up in the original
list is an implementation detail and being able to "destroy" the
original list has some performance benefits.

Personally, I find this behavior very surprising and think it would make
more sense to either set the input list to the final sorting result (in
addition to returning it) or not to modify the input. In the current
situation, one basically has to do something like (setq foo (sort foo))
anyway if one wants to continue using foo (or pass a copy of foo to sort
instead), which would no longer be necessary after this change (modulo
backwards compatibility).

Is there some rationale for sort working the way it does, that I am
missing here?

Cheers,
Daniel


[-- Attachment #2: Type: application/pgp-signature, Size: 835 bytes --]

             reply	other threads:[~2012-03-01 19:58 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-01 19:58 Daniel Schoepe [this message]
2012-03-01 20:52 ` Side effects of `sort' Tassilo Horn
2012-03-01 21:04 ` Dave Abrahams
2012-03-01 21:34   ` Daniel Schoepe
2012-03-01 22:25   ` Stefan Monnier
2012-03-02  6:13     ` Miles Bader

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8762eoum93.fsf@schoepe.localhost \
    --to=daniel@schoepe.org \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).