From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Newsgroups: gmane.emacs.bugs Subject: bug#47677: [PATCH] condition-case success continuation Date: Mon, 26 Apr 2021 13:53:26 +0200 Message-ID: <0CE64301-EF9E-4351-8CFC-6DD272B2B230@acm.org> References: <219007D9-0FD0-4AC2-A8B0-24A0FC277AE8@acm.org> <87lf9nzy48.fsf@gnus.org> <87F315E7-7F8A-46C5-A71B-F090F067D0B8@acm.org> <87sg3uskgt.fsf@gnus.org> <87zgy1qkni.fsf@gnus.org> <87wnsql3dg.fsf@gnus.org> Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.17\)) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="38353"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Stefan Kangas , Stefan Monnier , 47677@debbugs.gnu.org To: Lars Ingebrigtsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Apr 26 13:54:22 2021 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 1lazoi-0009fD-Nm for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 26 Apr 2021 13:54:20 +0200 Original-Received: from localhost ([::1]:33912 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lazoh-0004DG-RC for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 26 Apr 2021 07:54:19 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:41212) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lazoQ-0004CW-Qx for bug-gnu-emacs@gnu.org; Mon, 26 Apr 2021 07:54:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:33240) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lazoQ-0001wt-JW for bug-gnu-emacs@gnu.org; Mon, 26 Apr 2021 07:54:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lazoQ-0000A1-Hw for bug-gnu-emacs@gnu.org; Mon, 26 Apr 2021 07:54:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 26 Apr 2021 11:54:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 47677 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 47677-submit@debbugs.gnu.org id=B47677.1619438021592 (code B ref 47677); Mon, 26 Apr 2021 11:54:02 +0000 Original-Received: (at 47677) by debbugs.gnu.org; 26 Apr 2021 11:53:41 +0000 Original-Received: from localhost ([127.0.0.1]:44786 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lazo5-00009T-AQ for submit@debbugs.gnu.org; Mon, 26 Apr 2021 07:53:41 -0400 Original-Received: from mail1480c50.megamailservers.eu ([91.136.14.80]:59460 helo=mail118c50.megamailservers.eu) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lazo0-00009B-Dd for 47677@debbugs.gnu.org; Mon, 26 Apr 2021 07:53:40 -0400 X-Authenticated-User: mattiase@bredband.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=megamailservers.eu; s=maildub; t=1619438009; bh=7KxKiEe5f5xZJXjrtzCFuhgIs2WryH/ZEz+9cialPuk=; h=Subject:From:In-Reply-To:Date:Cc:References:To:From; b=SgdcWEUek/tKqM5t/Q7kkZ1d+MJJsRQm+2ywpxfJj5G+j8so6fWxtD2pUZo+DHr3/ fyBuiemck8WtK5CDQustRQi+EUl5aqfMcF/3T+6SSj+DN69qpNCuiv1EyC+aX2FUyX LvItK6AOKyEQr1w5dA2JkvNDRRft0RLRCfoN9G9U= Feedback-ID: mattiase@acm.or Original-Received: from [192.168.0.4] (c188-150-171-71.bredband.comhem.se [188.150.171.71]) (authenticated bits=0) by mail118c50.megamailservers.eu (8.14.9/8.13.1) with ESMTP id 13QBrR7b024808; Mon, 26 Apr 2021 11:53:28 +0000 In-Reply-To: <87wnsql3dg.fsf@gnus.org> X-Mailer: Apple Mail (2.3445.104.17) X-CTCH-RefID: str=0001.0A742F1F.6086A9B9.0047, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0 X-CTCH-VOD: Unknown X-CTCH-Spam: Unknown X-CTCH-Score: 0.000 X-CTCH-Flags: 0 X-CTCH-ScoreCust: 0.000 X-CSC: 0 X-CHA: v=2.3 cv=J9HUEzvS c=1 sm=1 tr=0 a=SF+I6pRkHZhrawxbOkkvaA==:117 a=SF+I6pRkHZhrawxbOkkvaA==:17 a=kj9zAlcOel0A:10 a=M51BFTxLslgA:10 a=OocQHUDgAAAA:8 a=EA0qI9qQgp634nb7qikA:9 a=CjuIK1q_8ugA:10 a=xUZTl98r3Qw_uB5NK3jt:22 X-Origin-Country: SE 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:204944 Archived-At: 25 apr. 2021 kl. 18.45 skrev Lars Ingebrigtsen : > condition-case is about handling errors -- it can be used as a general > flow control system, but that's an awkward fit. It conveys intention. > So I don't think we should extend it to handle more throw/catch-like > things. Most other languages use the same exception system for both errors and = 'throws'; the distinction in Lisp is an artefact of history. Both are = dynamically-scoped single-shot upwards-only value-conveying non-local = control transfers (or described in continuation terms with about as many = adjectives). The differences are minor. Several times I've had to hack around the inability of `catch` to = distinguish throws from normal termination and could go on doing so, but = it feels like making function calls by manual variable assignment, stack = operations and jumps. The byte code has no trouble expressing a more = useful catch; it's just an arbitrary restriction in our Lisp primitives. In addition, `catch` and `condition-case` don't compose. It would be = interesting to design primitives that do but since that seems tricky = (prove me wrong!), a unified `condition-case` does the job with a = minimum of fuss and is definitely not a hack. > However, I do agree that Emacs Lisp could need some beefing up in the > "early return" department Yes! But catch/throw is good for getting out of deep function call = chains which is not quite the same thing. They are hard to optimise well = for local use (exiting a loop or function) because it is difficult to = prove the absence of throws elsewhere. A variant of block/return-from would do, but better optimisations for = local functions (TCO in particular) may be at least as useful.