From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Andrea Corallo Newsgroups: gmane.emacs.devel Subject: Re: [PATCH] Add a mechanism for passing unibyte strings from lisp to modules. Date: Sun, 23 Jun 2024 17:15:39 -0400 Message-ID: References: <86v822jeqh.fsf@gnu.org> <225D336D-933E-4CA3-B245-89992D7E6C41@umanwizard.com> <86frt5jwtc.fsf@gnu.org> <87o77t6lyn.fsf@taipei.mail-host-address-is-not-set> <867cehgdn1.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="8334"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: "Brennan Vincent" , Stefan Kangas , emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Jun 23 23:15:51 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 1sLUYx-0001wb-KV for ged-emacs-devel@m.gmane-mx.org; Sun, 23 Jun 2024 23:15:51 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sLUYo-0006rh-HD; Sun, 23 Jun 2024 17:15:42 -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 1sLUYm-0006rH-Nv for emacs-devel@gnu.org; Sun, 23 Jun 2024 17:15:40 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sLUYm-0007Fx-1N; Sun, 23 Jun 2024 17:15:40 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:Date:References:In-Reply-To:Subject:To: From; bh=EDDrUxGXoN07w2LyzutJRJE/DWQWhzwvBvLxA7R5XRE=; b=IGW7Q9WASd8inHZaNdZB exJvt/45y+AAjbVcFBfdJjshHN7zLBiSNv8MKvcc0u3fplQIbq7/2GOBGHk3KBzCknB7ew4cPjLos CVR+bwugoVBdl4zWsF4hnGzpJPX5Si0HKnUNb4Y+DIfAcxYc6I9exdC7VKzHtT9RnkNTaVwsGYh2a wltw9dQV5A71MytHhu2a4diGIjtP+RnuMXTGCVzZJQur/cYRjf5X+3xIHTw5XvQRNr/M5z62z2tRa 4TfhUkTeib8sPd0u645uEfLDu9MdJlE1Oqn+hRb8pN0HDHk4cCPVLtKKAcCLZUx+9Gqe5TSJyjYlX XxfSK95ARNoEGA==; Original-Received: from acorallo by fencepost.gnu.org with local (Exim 4.90_1) (envelope-from ) id 1sLUYl-0003TG-FJ; Sun, 23 Jun 2024 17:15:39 -0400 In-Reply-To: <867cehgdn1.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 22 Jun 2024 19:12:34 +0300") 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:320580 Archived-At: Eli Zaretskii writes: >> From: "Brennan Vincent" >> Date: Sat, 22 Jun 2024 11:22:56 -0400 >>=20 >> Eli Zaretskii writes: >>=20 >> > 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. >>=20 >> 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. >>=20 >> 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. >>=20 >> Would you be open to such an approach? If so, I will send an updated pat= ch. > > 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 =F0=9F=A4=B7. 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