emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Lift {global,local}-key-binding to Lisp


From: Stefan Kangas
Subject: Re: Lift {global,local}-key-binding to Lisp
Date: Thu, 14 Jan 2021 13:24:10 -0600

Eli Zaretskii <eliz@gnu.org> writes:

> Stefan, why are we moving these and other functions to Lisp?  Are
> there any advantages to moving them?

AFAIK, the main reason to have things in C is if there is a performance
benefit to doing so.  The reason for this change (and the previous
commit) is simple: I noticed that there existed a handful of functions
in keymap.c that does not see any such performance benefit.

There is IMO no reason not to reduce the number of C primitives where
possible.  Lisp is a superior language to C, for all the usual reasons.
It is also better supported in Emacs itself in terms of debugging,
advising, etc.

As for future plans:

- I have a patch for `describe-buffer-bindings' that I intend to finish
  up soon (after fixing an unrelated performance regression bug).  This
  has more obvious benefits than the trivial case discussed here.

- There are a handful other functions in keymap.c that could usefully be
  moved to Lisp.

> And why don't we discuss such changes before making them?

If you prefer, I'm of course happy to send any patch for review before I
make any more changes like this.  I had already intended to do so for
the somewhat more complex case of `describe-buffer-bindings', but did
not realize it would be necessary for these trivial ones.

> In general, unless we get some significant gains, I'd prefer not to
> move around code just to move it.

It is hard to disagree with this point, in general.  But that was not
the reason for moving it, see above.

> If nothing else, it makes it harder for people who, like me, are
> familiar with the original code, to find stuff, because suddenly it
> isn't where it used to be.

The functions we are discussing here are rarely used, AFAICT, so I'm not
sure I understand this point.  Well, frankly I don't understand it even
if they were used a lot.

(FWIW, I use `xref-find-definitions' or `describe-function' to avoid
having to memorize the locations of functions.)

> It's a needless churn, and I ask myself what do we gain in
> return?

Emacs will be around in 40-50 years still, and we should maintain it
with that in mind.  Every time we make code more readable and
maintainable, we make our life easier in the long run.  Yes, at the
minor price of actually making the change.

Of course, any such change taken in isolation will look like something
we could also live without, but many such incremental improvements over
time will start to make a difference for the better.  Clean and
maintainable code is a good thing, and Lisp is better for that than C.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]