From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Daniel Schoepe Newsgroups: gmane.emacs.devel Subject: Side effects of `sort' Date: Thu, 01 Mar 2012 20:58:16 +0100 Message-ID: <8762eoum93.fsf@schoepe.localhost> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" X-Trace: dough.gmane.org 1330631923 4088 80.91.229.3 (1 Mar 2012 19:58:43 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 1 Mar 2012 19:58:43 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Mar 01 20:58:43 2012 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1S3C99-0007Wx-JR for ged-emacs-devel@m.gmane.org; Thu, 01 Mar 2012 20:58:39 +0100 Original-Received: from localhost ([::1]:40098 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S3C99-000572-3V for ged-emacs-devel@m.gmane.org; Thu, 01 Mar 2012 14:58:39 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:51012) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S3C95-00056N-QV for emacs-devel@gnu.org; Thu, 01 Mar 2012 14:58:37 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S3C93-0000AK-Q3 for emacs-devel@gnu.org; Thu, 01 Mar 2012 14:58:35 -0500 Original-Received: from mail-ee0-f41.google.com ([74.125.83.41]:50131) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S3C93-0000AE-GT for emacs-devel@gnu.org; Thu, 01 Mar 2012 14:58:33 -0500 Original-Received: by eeke53 with SMTP id e53so397034eek.0 for ; Thu, 01 Mar 2012 11:58:30 -0800 (PST) Received-SPF: pass (google.com: domain of daniel@schoepe.org designates 10.14.125.3 as permitted sender) client-ip=10.14.125.3; Authentication-Results: mr.google.com; spf=pass (google.com: domain of daniel@schoepe.org designates 10.14.125.3 as permitted sender) smtp.mail=daniel@schoepe.org; dkim=pass header.i=daniel@schoepe.org Original-Received: from mr.google.com ([10.14.125.3]) by 10.14.125.3 with SMTP id y3mr4040474eeh.9.1330631910172 (num_hops = 1); Thu, 01 Mar 2012 11:58:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=schoepe.org; s=google; h=from:to:subject:user-agent:date:message-id:mime-version :content-type; bh=xCBFC4jbHDTs9KNUCrTVt+FmPQ2AlmAUvjRY1FcYB20=; b=OWos2jAVNxUeqcopMQ44OaMF4Q1kweIqiDTqS3O2+giV334WHQ0Q7iV0uKc4ShAeTO FCnAP/nF1QGlfs036iK55nTe9KOiN3awBU1P7FRtRjZyjfXSLEcFQekbXXctjKOVyNVt LBvgICkk9eCqSg7+HS8KWRKIO262ljE5nMSMc= Original-Received: by 10.14.125.3 with SMTP id y3mr3095908eeh.9.1330631909889; Thu, 01 Mar 2012 11:58:29 -0800 (PST) Original-Received: from localhost (dslb-188-107-168-245.pools.arcor-ip.net. [188.107.168.245]) by mx.google.com with ESMTPS id i10sm10838752eea.8.2012.03.01.11.58.28 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 01 Mar 2012 11:58:28 -0800 (PST) User-Agent: Notmuch/0.11.1+212~gcd799cb (http://notmuchmail.org) Emacs/24.0.93.1 (x86_64-pc-linux-gnu) X-Gm-Message-State: ALoCoQnqkAXtq4kJTQdNI0Bjt7pXRQO7knj55Io8HOEVzGw04MjWtwj68cJ2uOq1sT8GwPdc6HM2 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 74.125.83.41 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:148863 Archived-At: --=-=-= Content-Type: text/plain 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 --=-=-= Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) iQIcBAEBAgAGBQJPT9TYAAoJEIaTAtce+Z+JrxsQAIGXE1zXxAjU1RIZhs5w8XJP lfYAsFWcEXQv6NK7GVUbhXLgrPTSl8s5jz6fbMKRGgSjDRtBYXBuFOhoNlZl5Le/ niyNv3zliq85D+VxB1XiSVje7ncKGnyzb8p3/YRxqLaujainCJlEx2Td4eLaoUc7 QkHq/3I6tzP1SbHsei2VR7fEs523DYq58MtAqT/6YmunPlfrthA5nVkJJitQ4/o7 Yvz6XumHNH2WVIGmEZErf1RSiImxpEcSGcGPlo42oQJIn7a6NvumtxdWlVRHlrBM EU9hOglpBA+9vNLUdMjqtnvlk9gkxXDkxJWCtRHambUrCc+GBzD8QPc1mkt0jffQ VeX8pMOEYUZpLT34Q86m8H40Sh10/6hIeuQShcAg+BCaw9TTBB/qpX5M3Wyq1a+6 PArQrOmeEGAF6jRYXaXixdTeoVcpjzrYJ61KxopEAVfejGf1JXdt0UeNgJ4RLH5d KEA4xNyvMfO8XzGNPIIUYoFcVM0USZKkI4zbYUxgMFQOpZA/NdxeXwvNu8JuGyJ9 SG98Kao08IS+1Jn4oTh2kmsL/VttNe/QOWsYEuIYNdYVIpXUqvSK5QzOH/gsyBGY wttWdpG6cudczAJSOJVEnmIY90nth4210K5pDFhZYb1bZVmhnR77i4C3HqZ4CJkq zc4Q6kR4j4Setr8MPgdc =kTy5 -----END PGP SIGNATURE----- --=-=-=--