From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.devel Subject: Re: Attaching context info to an error Date: Fri, 29 Dec 2023 17:19:37 +0000 Message-ID: References: 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="6821"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Stefan Monnier , emacs-devel@gnu.org To: =?iso-8859-1?Q?Jo=E3o_T=E1vora?= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Dec 29 18:20:45 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 1rJGXN-0001YS-0C for ged-emacs-devel@m.gmane-mx.org; Fri, 29 Dec 2023 18:20:45 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rJGWP-0006hS-DO; Fri, 29 Dec 2023 12:19:45 -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 1rJGWN-0006h2-TG for emacs-devel@gnu.org; Fri, 29 Dec 2023 12:19:43 -0500 Original-Received: from mail.muc.de ([193.149.48.3]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rJGWL-0003a2-1Q for emacs-devel@gnu.org; Fri, 29 Dec 2023 12:19:43 -0500 Original-Received: (qmail 71930 invoked by uid 3782); 29 Dec 2023 18:19:38 +0100 Original-Received: from acm.muc.de (pd953a7e3.dip0.t-ipconnect.de [217.83.167.227]) (using STARTTLS) by colin.muc.de (tmda-ofmipd) with ESMTP; Fri, 29 Dec 2023 18:19:37 +0100 Original-Received: (qmail 29864 invoked by uid 1000); 29 Dec 2023 17:19:37 -0000 Content-Disposition: inline In-Reply-To: X-Submission-Agent: TMDA/1.3.x (Ph3nix) X-Primary-Address: acm@muc.de Received-SPF: pass client-ip=193.149.48.3; envelope-from=acm@muc.de; helo=mail.muc.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_PASS=-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:314331 Archived-At: Hello, João. I'll admit I've not been following this thread closely, but, ... On Fri, Dec 29, 2023 at 03:43:54 +0000, João Távora wrote: > On Fri, Dec 29, 2023 at 2:55 AM Stefan Monnier wrote: > > > What object exactly goes into the handler bind handlers? > > The same (even `eq`) as the one passed to the `condition-case` handler. > Would it matter if it weren't? > > > Is it the funny cons? > > Yup. That's ELisp's current notion of an "error object". > > > Can we at least get some generic functions to hide that representation > > > so that we can change it later on? No, no, no. Please. (See below.) > > Patch very welcome, yes (and this is orthogonal to `handler-bind`). > What operations are typically requested from it? > - Printing? a cl-print-object would be sufficient, I think, > along with a (orthogonal) directive to 'format' for using > cl-prin1 (why doesn't cl-princ exist?) > - Getting the type for resignalling purposes? Unfortunately, > this returns 'cons' > (condition-case err (error "bla") (error (type-of err))) > Can it be made to return error? > - Can we import a typep (similar to cl-typep) that understands > basic types EIEIO and also error hierarchy? > - simple-condition-format-control and > simple-condition-format-arguments? > - change manual to explain that resignalling is discouraged now > that handler-bind exists, but if resignalling _is_ done, then > definitely avoid car and cdr and some form of > (signal (error-symbol err) (error-data err) > introducing these new functions? > - go through the hierarchy and add - > accessors? Or do we already consider these details of "data" to > to be hidden? If so, I think surely some violations exist, > hopefully not many. > They shouldn't be terribly hard to find. From some greps I > estimate there less than 700 condition-case that actually use > the variable and the majority seems to be resignalling or > printing. The former will probably be fixed by > handler-bind anyway, and printing is a generic operation > already. I checked about 20 occurances randomly, and they > all fell into this basket. This also tells me that switching > to proper objects isn't that hard. Talk about "generic functions" and "proper objects" makes me worried indeed. The Emacs error handling must work fully right from early bootstrap, i.e. when no Lisp has yet been loaded. The "proper object" for this is a list, of defined structure. This is approximately what we have at the moment. It would be useful to tighten up this definition. > João -- Alan Mackenzie (Nuremberg, Germany).