unofficial mirror of emacs-tangents@gnu.org
 help / color / mirror / Atom feed
From: Emanuel Berg <incal@dataswamp.org>
To: emacs-tangents@gnu.org
Subject: Re: [External] : Re: Shrinking the C core
Date: Mon, 18 Sep 2023 01:14:48 +0200	[thread overview]
Message-ID: <87a5tkcryv.fsf@dataswamp.org> (raw)
In-Reply-To: CAP_d_8UYw-N12MG=6Kmhj0WGSHLjvvQOp4mG16ktsxOyH9Pd9A@mail.gmail.com

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




  reply	other threads:[~2023-09-17 23:14 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <AM9PR09MB4977F8809CAACC854107D60596F0A@AM9PR09MB4977.eurprd09.prod.outlook.com>
2023-09-13 14:46 ` [External] : Re: Shrinking the C core Drew Adams
2023-09-14 12:09   ` Arthur Miller
2023-09-15 16:17     ` Emanuel Berg
2023-09-15 20:04       ` Drew Adams
2023-09-15 20:21         ` Emanuel Berg
2023-09-16 20:55           ` Drew Adams
2023-09-17 10:08             ` Emanuel Berg
2023-09-17 14:34               ` Yuri Khan
2023-09-17 23:14                 ` Emanuel Berg [this message]
2023-09-17 17:16               ` Drew Adams
2023-09-17 23:48                 ` Emanuel Berg
     [not found] <AM9PR09MB4977AE8A2555D914A8CB96ED96E1A@AM9PR09MB4977.eurprd09.prod.outlook.com>
     [not found] ` <87ledwx7sh.fsf@yahoo.com>
     [not found]   ` <DB9PR09MB4986737ABB230BFCEB1AB9B596E0A@DB9PR09MB4986.eurprd09.prod.outlook.com>
     [not found]     ` <877cpfybhf.fsf@yahoo.com>
     [not found]       ` <AM9PR09MB4977C010362EBF83BCF3491C96E0A@AM9PR09MB4977.eurprd09.prod.outlook.com>
     [not found]         ` <873503y66i.fsf@yahoo.com>
     [not found]           ` <AM9PR09MB49779854134CDC2E4FB2AD2996E0A@AM9PR09MB4977.eurprd09.prod.outlook.com>
     [not found]             ` <E1qbX63-0003Ty-Rn@fencepost.gnu.org>
     [not found]               ` <E1qdgsR-0000j8-BN@fencepost.gnu.org>
     [not found]                 ` <AM9PR09MB497757F8D921063E3D60D40C96EFA@AM9PR09MB4977.eurprd09.prod.outlook.com>
     [not found]                   ` <ZPhih7q2ml8v6EfP@ACM>
     [not found]                     ` <AM9PR09MB497758A94F012B506480CCE996EDA@AM9PR09MB4977.eurprd09.prod.outlook.com>
     [not found]                       ` <SJ0PR10MB548849E1E781201B1E2A9AC3F3EDA@SJ0PR10MB5488.namprd10.prod.outlook.com>
     [not found]                         ` <E1qfUyS-0006Wx-9e@fencepost.gnu.org>
     [not found]                           ` <ZP+B/SleQ0CTPWd2@thyrsus.com>
     [not found]                             ` <m2cyyoj9av.fsf@Pro.fritz.box>
2023-09-12 12:07                               ` Eli Zaretskii
2023-09-12 12:16                                 ` Po Lu
2023-09-12 19:58                                 ` Arthur Miller
2023-09-13 14:39                                   ` Eli Zaretskii
2023-09-14 11:53                                     ` Arthur Miller
2023-09-14 13:36                                       ` Po Lu
     [not found]                           ` <CALDnm50-__n48jSXe7WGXuT8O1YFm7QmqVzjgh-VUg5d_3ofpQ@mail.gmail.com>
     [not found]                             ` <87fs3fesir.fsf@dataswamp.org>
2023-09-15 15:35                               ` Drew Adams

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=87a5tkcryv.fsf@dataswamp.org \
    --to=incal@dataswamp.org \
    --cc=emacs-tangents@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.
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).