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.devel Subject: Re: Attaching context info to an error Date: Wed, 27 Dec 2023 15:27:04 -0500 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="27922"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: emacs-devel@gnu.org To: =?windows-1252?B?Sm/jbyBU4XZvcmE=?= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Dec 27 21:28:14 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 1rIaVi-00071i-0P for ged-emacs-devel@m.gmane-mx.org; Wed, 27 Dec 2023 21:28:14 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rIaUm-0007xC-Uk; Wed, 27 Dec 2023 15:27:16 -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 1rIaUk-0007wt-Bg for emacs-devel@gnu.org; Wed, 27 Dec 2023 15:27:15 -0500 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rIaUi-0000rw-JR for emacs-devel@gnu.org; Wed, 27 Dec 2023 15:27:14 -0500 Original-Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 5AACA10012E; Wed, 27 Dec 2023 15:27:11 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1703708830; bh=O8cINZwR6u5wCFjdrNH6LIPgGI8dJjISaHy1+mZuDW4=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=eUx4NPBue/Z6ro43EhIO1K3Od1WCpZagPJjG+FnGBZ41OkNXFzITP+AiUCqHxUJ6L Q+Fo8GsHG46UNuj4tT0XQ4k4JYEMGmSxcvXWYo5lmMqAO8O01k7f7p7lb9hs6gQ6yK O/og1ARL6Vp2R5dglVJFxQCggIem8OoC6vxvKiSZ1LiICX8TYE/cG/8+6eoZOgPOb4 LBtnzE4piDPY4h4M8XPY9yWYQi1QxClbef0qIUeNPKzPZ2Qw7ZRblk2JML7vaXXw+T O/gALTSB3+o2rYfE8yEBuathxWOs/3EVY+DuwHBVEUhpvAdMWHgYBcI894wjCsc1Wr tMyPJto9teLyw== Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 55B8210009E; Wed, 27 Dec 2023 15:27:10 -0500 (EST) Original-Received: from pastel (65-110-221-238.cpe.pppoe.ca [65.110.221.238]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 32108121061; Wed, 27 Dec 2023 15:27:10 -0500 (EST) In-Reply-To: (=?windows-1252?Q?=22Jo=E3o_T=E1vora=22's?= message of "Wed, 27 Dec 2023 19:27:10 +0000") Received-SPF: pass client-ip=132.204.25.50; envelope-from=monnier@iro.umontreal.ca; helo=mailscanner.iro.umontreal.ca X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_MED=-2.3, 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:314262 Archived-At: >> [ Not clear what `initialize-instance` would be used for. > It is passed the keyword arguments that are passed to CL:ERROR > or CL:SIGNAL [1,2]. Yes, I know, but that doesn't tell me what it lets us do that we can't do right now. > Though, I've noted before how our initialize-instance protocol > is inferior: It takes slots as its second argument, whereas is > should take initargs instead. This makes changing the > representation without changing the interface hard, but that > can be worked around with the slot-missing protocol. [ While Eric called it "slots" it holds the plist of initargs, just like the CLOS one. The only difference I know is that CLOS passes it as an `&rest` arg. You also told me that CLOS includes the "default" init args taken from the `defclass`, but I'm not familiar with those details (neither for CLOS nor for EIEIO). ] >> I also don't think `print-object` would be super useful, > It's useful when printing the human-readable error message isn't > appropriate say, because it takes multiple lines. I'm not sure the difference qualifies as "super useful". I don't mean to say we wouldn't be happy to be able to define ad-hoc methods for `cl-print-object` of error objects, but it's much too minor to motivate a change of representation. >> More importantly, that doesn't tell me what new things we could do, >> most importantly how to attach context info :-) > You can modify a condition object like you can any other > object. I'm afraid that doesn't tell me how to attach context to an error object. The context I'm talking about are orthogonal to the error objects themselves: any kind of context info could be attached to any kind of error object. I guess the only way this would help is if we had the foresight, when designing the root class for error objects, to include a `context` slot (even though it might go unused most of the time). Is that what you had in mind? >> > From a CL perspective, and even other languages, using our >> > "error symbol with some 'error property" representation of >> > errors is almost self-evidently inferior to just making it >> > a first class object. >> >> You don't need to convince me of that, indeed. But that's not what we >> have right now, and it's not trivial to retro-fit it cleanly in the >> current system. Luckily, AFAICT it's orthogonal to `handler-bind`. > > AFAICT CL:HANDLER-BIND is aware of inheritance [3], i.e. the > things you put in "type" of each handler binding in CL:HANDLER-BIND > are interpreted as designators of subclasses of CL:CONDITION and > dispatch similarly to generics. That shouldn't be too hard > to fit if we say `cl-condition` is the base class and > `cl-error` and `cl-warning` are its children, etc. What I mean is that if we start using something else than cons cells to represent error objects, loads of code will break because of things like: (condition-case err ... (error ... (signal (car err) (cdr err)))) -- Stefan