From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.bugs Subject: bug#47677: [PATCH] condition-case success continuation Date: Sat, 10 Apr 2021 19:52:19 -0400 Message-ID: References: <219007D9-0FD0-4AC2-A8B0-24A0FC277AE8@acm.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="33800"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: 47677@debbugs.gnu.org To: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Apr 11 01:53:15 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 1lVNPe-0008g8-Q6 for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 11 Apr 2021 01:53:15 +0200 Original-Received: from localhost ([::1]:40544 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lVNPd-0008SH-PS for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 10 Apr 2021 19:53:13 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:35052) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lVNPS-0008S5-7t for bug-gnu-emacs@gnu.org; Sat, 10 Apr 2021 19:53:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:42031) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lVNPR-0005Em-W8 for bug-gnu-emacs@gnu.org; Sat, 10 Apr 2021 19:53:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lVNPR-00076p-UX for bug-gnu-emacs@gnu.org; Sat, 10 Apr 2021 19:53:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 10 Apr 2021 23:53:01 +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.161809875027286 (code B ref 47677); Sat, 10 Apr 2021 23:53:01 +0000 Original-Received: (at 47677) by debbugs.gnu.org; 10 Apr 2021 23:52:30 +0000 Original-Received: from localhost ([127.0.0.1]:53577 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lVNOv-000762-NU for submit@debbugs.gnu.org; Sat, 10 Apr 2021 19:52:29 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:27101) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lVNOt-00075q-TX for 47677@debbugs.gnu.org; Sat, 10 Apr 2021 19:52:28 -0400 Original-Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 3EB41440C78; Sat, 10 Apr 2021 19:52:22 -0400 (EDT) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 93F3C440FA8; Sat, 10 Apr 2021 19:52:20 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1618098740; bh=eGV4QJ3O0PfjnXHtpHHzbmI0MJMdsnUDJ34lna0g60Y=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=In1/9N5+GZr0KD9QiIjwvGbiV+UOIXl5LcbdXb3Pf6vYw3WVjks0bZjA57rpYAWRU cmz4rud/6Bw64ugpZbwY2U7t7CH6yTsouKORG9vr2i5WVNs4KICCMJ12tAuzF2sEZI QuzmxVnPAfw+3WryqnXn6YV7v0K9x/Kt4ll8NZNw2Vrcw1YekokFQm0ZVDGIqtkNia COyA3J4xHtATRE5wxTFot0wUElgDGGU3vPAO+SR7i0n1xiTcc5Btf1Q4j+B3hDxNzi i1gWl0T0IW55fh/Z9bB4s1SpGXBlu41CmogqdQkHQ7yjAiLFRohxSZJl7mb3Kbbiie GVFOOFBwwvNVQ== Original-Received: from alfajor (104-222-126-84.cpe.teksavvy.com [104.222.126.84]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 2F9021202F2; Sat, 10 Apr 2021 19:52:20 -0400 (EDT) In-Reply-To: <219007D9-0FD0-4AC2-A8B0-24A0FC277AE8@acm.org> ("Mattias =?UTF-8?Q?Engdeg=C3=A5rd?="'s message of "Fri, 9 Apr 2021 22:26:49 +0200") 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:203826 Archived-At: > This patch adds the condition-case handler syntax > > (:success BODY) In the tests, you might want to add one with a lambda expression which captures a mutated success variable, as in (apply (condition-case res 42 (:success (prog1 (list (lambda (x) (+ res x)) res) (setq res 0))))) since this requires special handling in cconv.el. Other than that, the patch looks good to me. > Details of the syntax can be changed if there is a very good reason > for it. Many other languages have more or less independently added > equivalent constructs. Common Lisp's `handler-case` has a very similar > feature (:no-error). Any particular reason you chose ;success instead of :no-error? > It would be nice to give `catch` the same treatment. A particularly > flexible solution would be to add `catch` handlers to > `condition-case`, which would then be able to handle > everything. Unless there is a strong reason for doing it right away, > it can be seen as a later improvement. Let's take it one step at a time. Stefan