From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Gregory Heytings Newsgroups: gmane.emacs.bugs Subject: bug#56682: locked narrowing Date: Tue, 16 Aug 2022 21:18:21 +0000 Message-ID: <325f95fd2bae0e1bdd2a@heytings.org> References: <66bbbb95983414e79637@heytings.org> <83wnb9hadb.fsf@gnu.org> <395454dd-7238-c5d0-e924-2f65a186baa7@yandex.ru> <83r11hh4pm.fsf@gnu.org> <3a1232a17b09ce88af40@heytings.org> <83edxghqg2.fsf@gnu.org> <325f95fd2bcc0b666b0b@heytings.org> <83edxgfi75.fsf@gnu.org> <5e3c3081-f098-8140-c767-b895c32bf30b@yandex.ru> <835yisffil.fsf@gnu.org> <831qtgff78.fsf@gnu.org> <83zgg4dw4y.fsf@gnu.org> <83r11gdrr4.fsf@gnu.org> <325f95fd2b8688c3aa74@heytings.org> Mime-Version: 1.0 Content-Type: text/plain; format=flowed; charset=us-ascii Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="17706"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 56682@debbugs.gnu.org, Eli Zaretskii , dgutov@yandex.ru To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Aug 16 23:33:47 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1oO4C1-0004PX-Q3 for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 16 Aug 2022 23:33:46 +0200 Original-Received: from localhost ([::1]:35350 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oO4C0-0005eF-TX for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 16 Aug 2022 17:33:44 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:49412) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oO3xu-0007lo-4d for bug-gnu-emacs@gnu.org; Tue, 16 Aug 2022 17:19:10 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:58759) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oO3xm-0004il-Go for bug-gnu-emacs@gnu.org; Tue, 16 Aug 2022 17:19:09 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oO3xm-0001lO-9K for bug-gnu-emacs@gnu.org; Tue, 16 Aug 2022 17:19:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Gregory Heytings Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 16 Aug 2022 21:19:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 56682 X-GNU-PR-Package: emacs Original-Received: via spool by 56682-submit@debbugs.gnu.org id=B56682.16606847086732 (code B ref 56682); Tue, 16 Aug 2022 21:19:02 +0000 Original-Received: (at 56682) by debbugs.gnu.org; 16 Aug 2022 21:18:28 +0000 Original-Received: from localhost ([127.0.0.1]:48508 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oO3xD-0001kV-LU for submit@debbugs.gnu.org; Tue, 16 Aug 2022 17:18:27 -0400 Original-Received: from heytings.org ([95.142.160.155]:56498) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oO3x9-0001kJ-3f for 56682@debbugs.gnu.org; Tue, 16 Aug 2022 17:18:26 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=heytings.org; s=20220101; t=1660684701; bh=4JwLmeg4MpYkCyKk2J7RJ0AelD5d70kM5R14KGhZx7w=; h=Date:From:To:cc:Subject:In-Reply-To:Message-ID:References:From; b=g7Ncipb8BLyVYY1EdVKH18g1aE4Nv2DXK6XQ2Y0k7IGe2DGv1y0yb0YH/bKe60c9U 03ljQ06TD1+lJjxsPqk3QOjuAybfEraXBDYt3K2LBJP4zGmlrPYzM6t/0ogkqTGO+y DRIDKSnZq4aNKpiKnPuQzydlPyTH0qAlI2adWisGi55pskrCOTGuF2xG1zil86g/Tn P4IrvIeQwaXrBoOCoYnSPSFfqa/gN96HmjRS9MqabUH58Qq5maMSNSrN2KoEX5nTll iooQRusZaCK+YWyOkZcv9FQF1ap3wCwRQc+0VcibNaDhR6pXQoAowE5OaWIFdRnMH1 t1tE1/WoBGYig== In-Reply-To: X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:240011 Archived-At: > > Adding such a LOCK argument might be a good idea, actually, since ELisp > packages may also want to impose restrictions on widening (see my recent > message to `emacs-devel` about ELisp support for locked narrowing). > It might be a good idea indeed. I did not have an immediate need for it, and did not see how to do it (because of the unbalanced specbind). > > Why leave the `specbind (Qrestrictions_locked, Qt)` out of the function > when you've already included the 3 calls to `record_unwind_protect`? The > 4 share the same requirements (because `specbind` pushes on the > `specpdl`, just like `record_unwind_protect`). They naturally belong > together. > They do indeed, and that's actually what the original code did, but I was told that it was better to not do that. > > Also, a function that sometimes pushes to `specpdl` (and hence requires > the caller to do the `SPECPDL_INDEX + unbind_to` dance) and sometimes > not, depending on some value of its argument is a bit unnatural (it > complicates the reasoning when we try and convince ourselves that the > stack discipline of the specpdl is obeyed). So I'd recommend you split > the function into two: a first one that only does the narrowing itself > and a second one which calls the first plus unconditionally does the > `specbind+record_unwind_protect`. > Okay, thanks. That's probably another way to do it, indeed. >> Not "a lot", but indeed there's some redundancy there that could have >> been avoided. > > AFAICT it's more than half of the code of each branch. > That's still not "a lot", there are 12 statements in total in the two branches. And they have 3 statements in common...