From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: [PATCH] Add a mechanism for passing unibyte strings from lisp to modules. Date: Sat, 22 Jun 2024 19:12:34 +0300 Message-ID: <867cehgdn1.fsf@gnu.org> 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> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="37186"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: "Brennan Vincent" , Stefan Kangas , Andrea Corallo Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Jun 22 18:13:33 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 1sL3Mq-0009SQ-ML for ged-emacs-devel@m.gmane-mx.org; Sat, 22 Jun 2024 18:13:32 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sL3M7-0000gy-TR; Sat, 22 Jun 2024 12:12:47 -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 1sL3M1-0000ft-Si for emacs-devel@gnu.org; Sat, 22 Jun 2024 12:12:42 -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 1sL3M1-0001AA-9h; Sat, 22 Jun 2024 12:12:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=xctGIwk0iOqlQnDC8FkRq+X9h5cd2wb1tPQgHY1ueVM=; b=Jni1CgnfTtcC YXJeJRLLkE4JiJsm4/4wvteoM9/eR63igZCdRymoLREQkCRaUqcw6p04LadOFdBLZUI3zVxItm0V7 6q7vkx+cgnueUBMaicq73M3QlQravSDAZ2FbK0D3+/QF6Ri24wkj4orkJLk7aJLHII98y9JXtxnU5 Y7n87bfxm7vl5QJfTg9cbFDjKxfMDw+HcRtiPCKH9bUK/VANZbQ1GmBzka24CjiKTGmzPmGeC0WNW jE3u+t8q7u4OjbTiJUvzPP6PulgLqIm4awBM25CNOzI1t9Er2gJZZakoAprXqDpv/f6fOkLjscb2H 59UCQpCaKomIPq8r4kakeg==; In-Reply-To: <87o77t6lyn.fsf@taipei.mail-host-address-is-not-set> (brennan@umanwizard.com) 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:320472 Archived-At: > From: "Brennan Vincent" > Date: Sat, 22 Jun 2024 11:22:56 -0400 > > Eli Zaretskii 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?