From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Po Lu Newsgroups: gmane.emacs.devel Subject: Re: Shrinking the C core Date: Wed, 09 Aug 2023 20:34:56 +0800 Message-ID: <87il9owg0f.fsf@yahoo.com> References: <20230809094655.793FC18A4654@snark.thyrsus.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="14267"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: emacs-devel@gnu.org To: "Eric S. Raymond" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Aug 09 14:36:18 2023 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 1qTiQE-0003Sw-0g for ged-emacs-devel@m.gmane-mx.org; Wed, 09 Aug 2023 14:36:18 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qTiPF-0001db-KP; Wed, 09 Aug 2023 08:35:17 -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 1qTiPD-0001dC-Hj for emacs-devel@gnu.org; Wed, 09 Aug 2023 08:35:15 -0400 Original-Received: from sonic312-23.consmr.mail.ne1.yahoo.com ([66.163.191.204]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qTiPB-0002NU-DP for emacs-devel@gnu.org; Wed, 09 Aug 2023 08:35:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1691584510; bh=xDbHgYo+mmCk4a1XHnCB+PvNcLINQgjRH+vFS1hD6Kc=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From:Subject:Reply-To; b=lUqihyFRWZDq4tIoQJ0Usc+btlhrKn04++ldOVPvCl7jr33obx5LMf+wgTO0DM8G/Cd1FTG88UA1NE7fXSGuycLdnqTXwrQiNO1SFicaTsZRy94X4nCiBfp07XXu1dvh+6Bm3wvK7tmP5VvSGc7/0puc0vnawwZxgURPTCEAChfj2sCp8nOZoFBGqM07nu7rZqcfqlXIChUTOmwDCYgCerGhxCVD/VhH+YJclkDkC3TsuzrIJ+dniK97wvNiW0EjZQ5UWJ6lu3k/1Ru/sILIxfp/ckqUd82uphVm0K3QFn1G68SDuO7jHr8CB4sXtlWJOhNcsTMhT7I1KUQ1+X1anA== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1691584510; bh=jJpHbMxCGRfylz39ml2C0KXFsgG4rJvZw91gkSc+9zw=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=H2ygCmBx1a/xe5yMlTyDIEtsC5DJ8CD8ptPnlWAmhh7g2kloFXBpaNEmL5IW/xHxX0E5bvbQppzXa/LZooqiD+yxF+ud7lO4LKsiqOFXovg+O0LV4u5yj56MGIIkbb+rPXRDlb+jlumkr1XjSq2Q9Z1DEpTtO7GckvIqZ2+paWqiJEADde0x6O0dSFWMBL0uubI23898hein36JOUnbObW7KP6hBMAIH7Dal3ZD6EJoVQiQllo9eWVoPn+d+90hraIwevBOj/GeNFlCjtbz1tuaVhDUiW0bUN/zLDFIly00MKa5ZHn3C9RFwGiard/P8pzX9OWF4VQwGI0PXRLCHxQ== X-YMail-OSG: f5DaRsEVM1nw3LWLEWclxiOPLmcd929gCRhQ2w75z8VClbRIXlKKf.OdVX1LpBE vaG2xoN.sCljHPrHwNjOvBrJKKq10CClj1y0Dt9j42Dm_8t7Bt8eu15y5tGHzi9wqzRZLqQ2WLDO eAuEaawGY_P6shd2O4W9CbZRMzpTDZP9FFfHGb8bc9d4R4tu1CNrmTDJzvxMuGYsjqQsaPZK6DCm t.u2cv8SU92X.CWrWirZRe7jnmucZuDMW378vkhWC1MwHeqTwpUyVs93Lh2iAgaZb2bONocpOsBa yheHOr6PIWcIuiMTvaDFAT5TRq9.CQawnzPYhlE8iePeUCOwHXAOn4zzBz0FTyDRd8CnBy16KP11 ksJFjswu6rtMCxebynWGQAtuo9Nu0YyA8s8zBuDZ6xWMJ57wKCWmiNn4AlrJJOlWc.cuQMoz21Dg kKynfYbDI3uRRBbEgqJilhnVGhliBSHGtQCljgB.Kc088Hd2Cz4HPQOtxEOV1y.BKMQbLgqjeVks TP34mutaBv6sI2VIE2FJ9wVJHmzli9Odc3uo8onxdkqx2jx8IEvacxdGwZyVHZo1bmbiUVlvJOJG MGyhfJS1d9q5I.dLsHdteMyvEqUk0_B4Z13fVI47bpgSamlls.xK2Yv0r_riwjVOvV2C8VeLiBVe SdEQRG8wDwPUwqLnrGALOp4i6tYtVMSoHkjbytKN6Ub.N19Lqh2eS.0wYdveNDu7Nc28st3tpG4. Vbv3IJTrKrJVG_PY4bwi0XCpbzkK1aJVhTgEkoY8XVCjnw78V8yXvXpWF6Dm8b7Vh4W8NNfi27ql LJU19ZxB4PNJGg.faqB8xKRz.eHe1XGroYzC8YX.B. X-Sonic-MF: X-Sonic-ID: 9624a842-8e89-48b5-b1e2-692caa64eae0 Original-Received: from sonic.gate.mail.ne1.yahoo.com by sonic312.consmr.mail.ne1.yahoo.com with HTTP; Wed, 9 Aug 2023 12:35:10 +0000 Original-Received: by hermes--production-sg3-69654d8bd-d8v2r (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID e985fce8361b2f20f33c88e193525870; Wed, 09 Aug 2023 12:35:03 +0000 (UTC) In-Reply-To: <20230809094655.793FC18A4654@snark.thyrsus.com> (Eric S. Raymond's message of "Wed, 9 Aug 2023 05:46:55 -0400 (EDT)") X-Mailer: WebService/1.1.21695 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.yahoo Received-SPF: pass client-ip=66.163.191.204; envelope-from=luangruo@yahoo.com; helo=sonic312-23.consmr.mail.ne1.yahoo.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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:308470 Archived-At: "Eric S. Raymond" writes: > Recently I have been refamiliarizing myself with the Emacs C core. > > Some days ago, as a test that I understand the C core API and the > current build recipe, I made and pushed a small commit that moved > the policy code in delete-file out to Lisp, basing it on a smaller > and simpler new entry point named delete-file-internal (this is > parallel to the way delete-directory is already partitioned). > > I've since been poking around the C core code and am now wondering why > there is so much C-core code that seems like it could be pushed out to > Lisp. For example, in src/fileio.c: > > DEFUN ("unhandled-file-name-directory", Funhandled_file_name_directory, > Sunhandled_file_name_directory, 1, 1, 0, > doc: /* Return a directly usable directory name somehow associated with FILENAME. > A `directly usable' directory name is one that may be used without the > intervention of any file name handler. > If FILENAME is a directly usable file itself, return > \(file-name-as-directory FILENAME). > If FILENAME refers to a file which is not accessible from a local process, > then this should return nil. > The `call-process' and `start-process' functions use this function to > get a current directory to run processes in. */) > (Lisp_Object filename) > { > Lisp_Object handler; > > /* If the file name has special constructs in it, > call the corresponding file name handler. */ > handler = Ffind_file_name_handler (filename, Qunhandled_file_name_directory); > if (!NILP (handler)) > { > Lisp_Object handled_name = call2 (handler, Qunhandled_file_name_directory, > filename); > return STRINGP (handled_name) ? handled_name : Qnil; > } > > return Ffile_name_as_directory (filename); > } > > Why is this in C? Is there any reason not to push it out to Lisp and > reduce the core complexity? There is a plenitude of such reasons. Whenever some code is moved to Lisp, its structure and history is lost. Often, comments within the extracted C code remain, but the code itself is left ajar. Bootstrap problems are frequently introduced, as well as latent bugs. And Emacs becomes ever so much slower. These are not simply theoretical concerns, but problems I've encountered many times in practice. Compounding that, fileio.c is abundant with complex logic amended and iteratively refined over many years, which is dangerously prone to loss or mistranscription during a refactor or a rewrite. Finally, this specific case is because we don't want to provide Lisp with an easy means to bypass file name handlers. All primitives operating on file names should thus consult file name handlers, enabling packages like TRAMP to continue operating correctly. > More generally, if I do this kind of refactor, will I be stepping on > anyone's toes? Probably. I think a better idea for a first project is this item in etc/TODO: ** A better display of the bar cursor Distribute a bar cursor of width > 1 evenly between the two glyphs on each side of the bar (what to do at the edges?). which has been on my plate for a while. I would be grateful to anyone who decides to preempt me. Thanks in advance!