From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Michael Heerdegen via "Emacs development discussions." Newsgroups: gmane.emacs.devel Subject: Re: master 4b79c80c999 1/2: New function 'sort-on' Date: Fri, 02 Feb 2024 17:43:11 +0100 Message-ID: <87eddu24ww.fsf@web.de> References: <170688047526.14693.2994051491358257471@vcs2.savannah.gnu.org> <20240202132756.4272CC0EFE7@vcs2.savannah.gnu.org> <87cytej4hy.fsf@daniel-mendler.de> <86zfwi52m1.fsf@gnu.org> <87plxe28as.fsf@web.de> <877cjmj2vo.fsf@daniel-mendler.de> <87jznm26io.fsf@web.de> <87sf2ahm2y.fsf@daniel-mendler.de> Reply-To: Michael Heerdegen Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="16820"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) To: emacs-devel@gnu.org Cancel-Lock: sha1:ynbzpDnFjrYj5CYdR1/LSH2HDWE= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Feb 02 17:43:37 2024 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rVwdd-0004DY-GY for ged-emacs-devel@m.gmane-mx.org; Fri, 02 Feb 2024 17:43:37 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rVwd0-0005AS-SJ; Fri, 02 Feb 2024 11:42:58 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rVwcz-0005A7-E7 for emacs-devel@gnu.org; Fri, 02 Feb 2024 11:42:57 -0500 Original-Received: from ciao.gmane.io ([116.202.254.214]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rVwcx-0004Wc-Ss for emacs-devel@gnu.org; Fri, 02 Feb 2024 11:42:57 -0500 Original-Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1rVwcv-0003RB-Nx for emacs-devel@gnu.org; Fri, 02 Feb 2024 17:42:53 +0100 X-Injected-Via-Gmane: http://gmane.org/ Received-SPF: pass client-ip=116.202.254.214; envelope-from=ged-emacs-devel@m.gmane-mx.org; helo=ciao.gmane.io X-Spam_score_int: -13 X-Spam_score: -1.4 X-Spam_bar: - X-Spam_report: (-1.4 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FORGED_FROMDOMAIN=0.25, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 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-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:315767 Archived-At: Daniel Mendler via "Emacs development discussions." writes: > Right. It is not pretty that some operations in seq.el do not generalize > to infinite sequences. The current situation is that `seq-sort' is only implemented for lists and arrays, i.e. "sequences" in the narrow sense of the Elisp manual. All types are transformed into a list and use the "sort" algorithm for lists, and then the results are transformed back into the original type. That's not such a useful abstraction, but ok... > I would find it better if a similar function is not duplicated in > multiple files, which would be the case if both `sort-on' and > `seq-sort-on' are added. It's worse: we already have `seq-sort-on': it's called `seq-sort-by' which is a `sort-on' but not as efficient when the key function is not trivial. > > But do you really think people often would "sort-on" anything but lists? > > Yes. Sorting vectors is a useful operation. If the function is not added > to seq.el it should maybe operate on the list or vector in a destructive > manner for efficiency? That's probably your field, I dunno. If there is a key function that is not cheap, the difference is probably not worth it. Without a key function this is a separate question, and the solution ... wait: `sort' already does sort vectors, right? Michael.