From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Emanuel Berg Newsgroups: gmane.emacs.tangents Subject: Re: [External] : Re: Shrinking the C core Date: Mon, 18 Sep 2023 01:14:48 +0200 Message-ID: <87a5tkcryv.fsf@dataswamp.org> References: <87cyyje7hh.fsf@dataswamp.org> <871qezdw6a.fsf@dataswamp.org> <87h6ntcdt5.fsf@dataswamp.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="10212"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) To: emacs-tangents@gnu.org Cancel-Lock: sha1:dyCOQ9k/nsS/RxHiMz1Kb9GmmxQ= Original-X-From: emacs-tangents-bounces+get-emacs-tangents=m.gmane-mx.org@gnu.org Mon Sep 18 04:20:27 2023 Return-path: Envelope-to: get-emacs-tangents@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 1qi3sB-0002QE-1g for get-emacs-tangents@m.gmane-mx.org; Mon, 18 Sep 2023 04:20:27 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qi3rZ-0008LJ-Nr; Sun, 17 Sep 2023 22:19:49 -0400 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 1qi0yi-0007yI-FV for emacs-tangents@gnu.org; Sun, 17 Sep 2023 19:15:00 -0400 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 1qi0yg-0007mR-HS for emacs-tangents@gnu.org; Sun, 17 Sep 2023 19:15:00 -0400 Original-Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1qi0ye-0007iX-RJ for emacs-tangents@gnu.org; Mon, 18 Sep 2023 01:14:56 +0200 X-Injected-Via-Gmane: http://gmane.org/ Mail-Followup-To: emacs-tangents@gnu.org Mail-Copies-To: never Received-SPF: pass client-ip=116.202.254.214; envelope-from=get-emacs-tangents@m.gmane-mx.org; helo=ciao.gmane.io X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, HEADER_FROM_DIFFERENT_DOMAINS=0.249, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Sun, 17 Sep 2023 22:19:47 -0400 X-BeenThere: emacs-tangents@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Emacs news and miscellaneous discussions outside the scope of other Emacs mailing lists List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-tangents-bounces+get-emacs-tangents=m.gmane-mx.org@gnu.org Original-Sender: emacs-tangents-bounces+get-emacs-tangents=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.tangents:1102 Archived-At: Yuri Khan wrote: > 1. a couple of functions > a. ‘(my-sort-by SEQ LESSP)’ where LESSP is a function accepting two > elements X and Y and returning ‘t’ when X should be > sorted before Y, and > b. ‘(my-sort-on SEQ KEY)’ where KEY is a function accepting an > element X and returning a number such that sorting by > that number yields the desired order; or > > 2. a single function that could be called as ‘(my-sort SEQ > :by LESSP)’ or ‘(my-sort SEQ :key KEY)’, with the same > semantics as above? > > Does your answer change if we want to extend the API to also > support sorting in descending order? If it does, how? If there are several tendencies and in particular if those can be combined one can absolutely use keywords (and extend by adding more), but then we are at a level of complexity which would translate to a huge amount of envisioned simple, one or two argument functions, so instead of doing that, if one were to stay at the simple function end of the spectrum, one would use combinations of such simple functions, e.g. (reverse (sort ... )) At the opposite end where functions are insanely complex, keywords are a way to make the interface more clear and facilitate the submission of arguments from code. So it is good keywords exist when it is complicated, in general I prefer it when it is simple but sometimes the complexity is such it is actually easier to not try to keep it simple - since that is impossible - but to stay at the complex side and take it from there. Optional arguments don't really belong on that simple/complex scale, rather they should be used when there is an intuitive default, for example (forward-line &optional N) where N defaults to 1. -- underground experts united https://dataswamp.org/~incal