From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Thuna Newsgroups: gmane.emacs.bugs Subject: bug#72279: [PATCH] Non-local exits from outside the lexical scope are caught by cl-block Date: Fri, 26 Jul 2024 02:41:59 +0200 Message-ID: <87cyn13rxk.fsf@gmail.com> References: <87wmla4rqq.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="30917"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Stefan Monnier To: 72279@debbugs.gnu.org Cancel-Lock: sha1:JnviE6VGNkdy2V1LqFxql4Hz1u4= Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Jul 26 02:44:22 2024 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 1sX94H-0007yC-VS for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 26 Jul 2024 02:44:21 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sX93v-0000o9-60; Thu, 25 Jul 2024 20:43:59 -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 1sX93r-0000YM-A8 for bug-gnu-emacs@gnu.org; Thu, 25 Jul 2024 20:43:55 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sX93r-0003UY-1r for bug-gnu-emacs@gnu.org; Thu, 25 Jul 2024 20:43:55 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sX93y-0007o1-Gc for bug-gnu-emacs@gnu.org; Thu, 25 Jul 2024 20:44:02 -0400 X-Loop: help-debbugs@gnu.org In-Reply-To: <87wmla4rqq.fsf@gmail.com> Resent-From: Thuna Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 26 Jul 2024 00:44:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 72279 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.172195459329938 (code B ref -1); Fri, 26 Jul 2024 00:44:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 26 Jul 2024 00:43:13 +0000 Original-Received: from localhost ([127.0.0.1]:38032 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sX93A-0007mo-OS for submit@debbugs.gnu.org; Thu, 25 Jul 2024 20:43:13 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:42382) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sX936-0007md-Uo for submit@debbugs.gnu.org; Thu, 25 Jul 2024 20:43:11 -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 1sX92y-0005Id-PS for bug-gnu-emacs@gnu.org; Thu, 25 Jul 2024 20:43:00 -0400 Original-Received: from ciao.gmane.io ([116.202.254.214]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sX92x-0003Ik-8c for bug-gnu-emacs@gnu.org; Thu, 25 Jul 2024 20:43:00 -0400 Original-Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1sX92v-0006nd-5k for bug-gnu-emacs@gnu.org; Fri, 26 Jul 2024 02:42:57 +0200 X-Injected-Via-Gmane: http://gmane.org/ Received-SPF: pass client-ip=116.202.254.214; envelope-from=geb-bug-gnu-emacs@m.gmane-mx.org; helo=ciao.gmane.io X-Spam_score_int: 0 X-Spam_score: 0.0 X-Spam_bar: / X-Spam_report: (0.0 / 5.0 requ) BAYES_00=-1.9, DKIM_ADSP_CUSTOM_MED=0.001, FORGED_GMAIL_RCVD=1, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.001, NML_ADSP_CUSTOM_MED=0.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action 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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:289343 Archived-At: > BTW, for the second patch a simpler solution is to expand > > (cl-block A FOO) > to > (let ((cl--block--A ',(make-symbol "A"))) > (catch cl--block--A FOO)) > > and > > (cl-return B FOO) > to > (throw cl--block--B FOO) > > which will signal an "unknown variable cl--block--B" if a `cl-return` is > used outside of its block. Aha, yes, that would indeed be simpler. > But the optimization of `cl-block` when the tag is not used is > important, so I don't think it's a good approach. I don't have any particular complaints against keeping this optimization, but for the record would you be able to expand on what exactly the problem is? It doesn't seem obvious to me that unused `catch'es would make such a meaningful difference. > Yup, as I said, the "optimization" is important (most of the > `cl-block`s are implicit and unused, IME). It would be nice if this would be documented at least in a comment above `cl-block', even though it's unlikely that it will see too many changes. >> I see two possible solutions, either define a (setf catch) or switch >> to defsubst instead of cl-defsubst. > > I don't think we can implement a `setf catch` (tho we could probably > come up with a hack which works in practice for those > cl-defstruct slots). 🙁 > > IIRC for the slot accessors `defsubst` would lead to worse code than > what we currently get with `cl-defsubst` so it wouldn't be as good, but > I believe we could use `define-inline` instead. That sounds like a solution. Defining a hack for `setf catch' seems like it would lead to a lot of problems down the line, so it would be better to put it off until someone comes up with a good way to do it (though I doubt it is possible given dynamic exits).