unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Andrea Corallo <acorallo@gnu.org>
To: Eli Zaretskii <eliz@gnu.org>
Cc: "Brennan Vincent" <brennan@umanwizard.com>,
	 Stefan Kangas <stefankangas@gmail.com>,
	 emacs-devel@gnu.org
Subject: Re: [PATCH] Add a mechanism for passing unibyte strings from lisp to modules.
Date: Sun, 23 Jun 2024 17:15:39 -0400	[thread overview]
Message-ID: <yp1ikxze4xw.fsf@fencepost.gnu.org> (raw)
In-Reply-To: <867cehgdn1.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 22 Jun 2024 19:12:34 +0300")

Eli Zaretskii <eliz@gnu.org> writes:

>> From: "Brennan Vincent" <brennan@umanwizard.com>
>> Date: Sat, 22 Jun 2024 11:22:56 -0400
>> 
>> Eli Zaretskii <eliz@gnu.org> writes:
>> 
>> > Why can't you have the module code itself read the file, instead of
>> > getting the bytes from Emacs?  Passing large amounts of bytes from
>> > Emacs to a module is a very inefficient way of talking to modules
>> > anyway, because Emacs is not optimized for moving text to and fro in
>> > the shape of Lisp strings.  To say nothing of the GC pressure you will
>> > have in your mode, due to a constant consing of strings.  It is best
>> > to avoid all that to begin with.
>> 
>> Of course it's possible to do that, but I wanted to write my mode in
>> elisp as much as possible and keep the C side minimal, simply because I
>> find elisp a much more enjoyable language to use. But if
>> you are opposed to adding this code I can go with that approach.
>> 
>> Another possibility which would avoid adding specifically
>> unibyte-related surface area to the modules API would be to create an
>> extended version of copy_string_contents which can take any coding
>> system, rather than forcing UTF-8.
>> 
>> Would you be open to such an approach? If so, I will send an updated patch.
>
> I very much dislike the idea of letting modules deal with unibyte
> strings, for the reasons I explained.  Basically, it will open a large
> Pandora box by allowing people who don't know enough about the
> subtleties of unibyte strings in Emacs to write buggy modules which
> will crash Emacs.
>
> But let's hear the other co-maintainers.  Stefan and Andrea, what is
> your POV on these issues?

I, for one, would be not too much worried.  People writing modules
should be already very responsible for what they write as they have
already plenty of ways to shoot in their feet 🤷.

Perhaps we could mitigate the risk with some doc/comment explaining the
specific usecase this interface is meant to serve so it's not miss-used?

  Andrea



  reply	other threads:[~2024-06-23 21:15 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-21 18:13 [PATCH] Add a mechanism for passing unibyte strings from lisp to modules Brennan Vincent
2024-06-21 18:13 ` Brennan Vincent
2024-06-21 19:08 ` Eli Zaretskii
2024-06-21 20:14   ` Brennan Vincent
2024-06-22  6:50     ` Eli Zaretskii
     [not found]       ` <87o77t6lyn.fsf@taipei.mail-host-address-is-not-set>
2024-06-22 16:12         ` Eli Zaretskii
2024-06-23 21:15           ` Andrea Corallo [this message]
2024-06-24 11:45             ` Eli Zaretskii
2024-06-25 17:36               ` Brennan Vincent
2024-06-26 12:26                 ` Eli Zaretskii
2024-06-26 12:39                   ` tomas
2024-06-26 13:23                     ` Eli Zaretskii
2024-06-26 13:33                       ` tomas
2024-06-26 14:32                         ` Brennan Vincent
2024-06-26 15:53                           ` Eli Zaretskii
2024-06-26 15:34                         ` Eli Zaretskii
2024-06-27  3:36                           ` Brennan Vincent
2024-06-27  6:05                             ` Eli Zaretskii

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=yp1ikxze4xw.fsf@fencepost.gnu.org \
    --to=acorallo@gnu.org \
    --cc=brennan@umanwizard.com \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=stefankangas@gmail.com \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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).