From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?UTF-8?B?Sm/Do28gVMOhdm9yYQ==?= Newsgroups: gmane.emacs.devel Subject: Re: Attaching context info to an error Date: Tue, 26 Dec 2023 22:43:52 +0000 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="22093"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Dec 26 23:45:03 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 1rIGAZ-0005XP-9i for ged-emacs-devel@m.gmane-mx.org; Tue, 26 Dec 2023 23:45:03 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rIG9p-0003Fz-GN; Tue, 26 Dec 2023 17:44:18 -0500 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 1rIG9j-0003DQ-Cw for emacs-devel@gnu.org; Tue, 26 Dec 2023 17:44:11 -0500 Original-Received: from mail-lj1-x234.google.com ([2a00:1450:4864:20::234]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rIG9f-0001Y7-4J for emacs-devel@gnu.org; Tue, 26 Dec 2023 17:44:09 -0500 Original-Received: by mail-lj1-x234.google.com with SMTP id 38308e7fff4ca-2ccba761783so20822271fa.1 for ; Tue, 26 Dec 2023 14:44:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1703630644; x=1704235444; darn=gnu.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=s8MT/Cdwoz7N+tdfR6W6sUBY4pgVFxujquRFKHpUrpU=; b=UnoOqYRcXinagsVnbNOR3fWIyfdGJnEyIteKorAxa0FyQ9Dy8sn47u9R7wm2MHcTWm hMRA5NDw8HZGhQj6vzPb+teYc/jQ1s/fSDuePa0ThKZlo3vvyaEN0Am0weI3RWcono+n wCL/bRKo3cNzH69ocH+KqBgmpQAfe4DkD3nX4og6Hc1FMlFfq08zX4f3OuY20KLLwt01 uiIy9gVD1s8HhdW1BaRFYZdxtqSR0qFqKRbKqKKVl6lX6ZUm5cKmV3lRIslm7XN3EVsk fciSa0Rtyou25DcfZbHgMYJMnJa43eg5WdFqECKAl22vTwByCZHrbeEf/XiKuD7luBmg r4Mg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703630644; x=1704235444; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=s8MT/Cdwoz7N+tdfR6W6sUBY4pgVFxujquRFKHpUrpU=; b=pCt1+8ICsyzTHXdvIc0J4b0DqLjGmEExIUYUu47wIGaGwKrod0bJuPTN68dMA7wAAE 8uxo01dw+Z+kWvqaSAocdEvMg3KMezsbaWhPyoVyNIiU8stIA3PxgO1p1x+tH/IErvkV 1nyXFg/doCsBm+5rHDXIYY2T9JbCzAXIkFRG5E4ULdQWGIj8WDoRfFWNvxD4L7kuL7o5 AJuZ9hHPn0cLWQVOw1sunF0mZmH5E7TzB/Oy8Jcp7/2hiuCDTXdueLvOvQFsedePuHMw jhMCEce17aPNxa7dvHXavrcJ4+EEe5XbktZuRpPfZSecJDSWs8zCxvAttGIQgDvmfM4K OU5g== X-Gm-Message-State: AOJu0YxxBC8sowaPaa6Z0LTBTUmIQEmhvErn/gyjr0WcrB3cLPGoVw93 HXWSObjaoh7bWPg/jn7eYsfMAt2GLYvtnlAemqEc6EZ8Bgs= X-Google-Smtp-Source: AGHT+IHvCtxYe0gizZlCiaJ+VMzG1xwefm2TvynbgMOt66cdQSNLKScWT8lOe7zg04s+ZjmAG7e3Ntr2SxTfDf/q7H4= X-Received: by 2002:a2e:a277:0:b0:2cc:7913:f34c with SMTP id k23-20020a2ea277000000b002cc7913f34cmr3596634ljm.59.1703630643939; Tue, 26 Dec 2023 14:44:03 -0800 (PST) In-Reply-To: Received-SPF: pass client-ip=2a00:1450:4864:20::234; envelope-from=joaotavora@gmail.com; helo=mail-lj1-x234.google.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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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:314232 Archived-At: On Tue, Dec 26, 2023 at 8:47=E2=80=AFPM Stefan Monnier wrote: > > >> I'm playing with `handler-bind` and trying to see how we could make us= e > >> of such a functionality in Emacs. > > *loud cheers* > [...] > > Amongst the killer weaponry this gives us is a restart system, > > finally. > > I fail to see the connection, to be honest. The restarts themselves can be made with simply try/catch, you're right, but automatically invoking restarts with certain parameters based on different each error object can only be done with handler-bind AFAIK. Also, for restarts to become visible/invisible according to some information in the condition themselves (the type of error or some other cookie) we also need handler-bind to attach that cookie to the condition object. Typically, a restart gives you the option to try again with something different (not just try again as I did in this poc), like if a network connection fails, you're given the option to try with new credentials, or a different protocol, etc... > And why `handler-bind`. IOW, why wait until the error happens before > pushing the retry onto the list? Why not just: > > (defun pm/call-with-retry-restart (outer inner msg fn) > (catch outer > (let ((pm/restarts > (cons (list 'retry msg > (lambda () (throw inner nil)))))) > (while t > (catch inner > (throw outer (funcall fn))))))) Probably, this was a thinko, or I was trying to simulate visibility of a restart like I described above, but there are much better ways to do that. Anyway, as Gerd suggested, I would suggest at least supporting EIEIO in this handler-bind. This needn't necessarily clash with our "error symbols" if the dispatching is done via generic functions right? The usual performance setbacks of EIEIO object shouldn't be a problem as conditions are meant to represent exceptional situations by definition. The counterpart to handler-bind is handler-case btw (which is more or less our condition-case).