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: Wed, 27 Dec 2023 18:08:25 +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="37070"; 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 Wed Dec 27 19:09:28 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 1rIYLQ-0009Qs-Az for ged-emacs-devel@m.gmane-mx.org; Wed, 27 Dec 2023 19:09:28 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rIYKi-0007mm-2r; Wed, 27 Dec 2023 13:08:44 -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 1rIYKf-0007l1-9o for emacs-devel@gnu.org; Wed, 27 Dec 2023 13:08:42 -0500 Original-Received: from mail-lj1-x235.google.com ([2a00:1450:4864:20::235]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rIYKd-0000xL-FN for emacs-devel@gnu.org; Wed, 27 Dec 2023 13:08:41 -0500 Original-Received: by mail-lj1-x235.google.com with SMTP id 38308e7fff4ca-2cb21afa6c1so65704701fa.0 for ; Wed, 27 Dec 2023 10:08:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1703700517; x=1704305317; 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=uXG09+a9grRxl83U4lrvmxfkxq2JeX7hkBRioghUbiw=; b=O7kHRhQCwetKOIH7R4qpsgLZ31wEkgOsSDiSX4ozjYSxllWkQeAvN2KfchOUcq2AsG azcTAC4hESA75hnPT3TR1JwxYJawfUHE0puhwbWC7mi1bmEJt6PuN52n1zRTWYOR76hx l6kEaA0hzyjStu7R9HJ4zE57B8TtGhogiX+oGrO8CjmTpTeqj9xHIM3b8eyNdGyghE7d ego6T3RGJCDwnI6LFMue0DKAWEgPaWIUp+53b2yOvZapNCvvrf5CJO75zEpDScvwgLSL eRXc7YfdwrxJD1vGgIbUab0HBV/0ZuFBwN5a/kC11q4ee/zBU/WQZ5jR4SLoFYYyD2Ma 1kyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703700517; x=1704305317; 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=uXG09+a9grRxl83U4lrvmxfkxq2JeX7hkBRioghUbiw=; b=eM2O3YtRiJtUyQzI1VtdkDNXiV6lvYZvbiL2hQ4AiBPN6cvkY9nB6/WYB0hsnMuV2b vM8+woBb7QtPe8UAW7vC3a9Z49FqKO+gcSYnnV4OG87r9KefEKgGyTy1BR/EAhVqcxKi a6NGIUdHWe/m+DlmhpS0juRFG7Zz/mtjNPxVxc+vPeAOGkfTqcTh5jOP44o+aIamytUn ENbZit8QKStskCbTCb3D3sFHVqmHdDxejYCGe61+7UslDQCAjRL6wjE5YmV+GnNoNs4t lT80LRZRo7DaIdwnCJzo7zZW9HW4MLgyuUzpWlZUd78ZrwVKPrSQXF88zkPd9tpBL4Os 4biw== X-Gm-Message-State: AOJu0YxZ1kYFZGhobDnZFMKIZM8Kxhg+GRG59/hVmQ+hfdr+HTQvpUKM YIKEqhf0ZPh6ssRB5owDR4y/firhDWr7Qoh/ZEnr/9pjF94= X-Google-Smtp-Source: AGHT+IH+RZT+8kJDg++0YKJFg1EmIJQ0jAEFTxT9OydZcduYIvvGJGibIdSQ3d0pVy95DmTjGgk5SiHbTp9LcXCgjvs= X-Received: by 2002:a05:651c:b1e:b0:2cc:ad9b:8807 with SMTP id b30-20020a05651c0b1e00b002ccad9b8807mr4594132ljr.81.1703700517230; Wed, 27 Dec 2023 10:08:37 -0800 (PST) In-Reply-To: Received-SPF: pass client-ip=2a00:1450:4864:20::235; envelope-from=joaotavora@gmail.com; helo=mail-lj1-x235.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:314252 Archived-At: On Wed, Dec 27, 2023 at 5:50=E2=80=AFPM Stefan Monnier wrote: > > > Anyway, as Gerd suggested, I would suggest at least supporting > > EIEIO in this handler-bind. > > Could you give some concrete examples of things you'd (be able to) do > with it? Just look at anyCL program that uses conditions, there are very many of them. One of them is Snooze [1] which uses them to represent HTTP error codes. First, we'd have to be able to `signal` such objects. And then, CLOS is good :-) you get access to lots of existing useful protocols. initialize-instance, print-object, etc for free. > Given that we start with (signal ERROR-SYMBOL ERROR-DATA) and the "other > end point" of an error is the `condition-case` variable bound to > a value of the form (ERROR-SYMBOL . ERROR-DATA), I find it a bit hard to > see how we could usefully use "objects" somewhere in-between, but maybe > some examples can help me out of the rut. >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. (define-condition my/condition (error) docstring (slots...)) Which is a much more normal way to define a hierarchy of exceptions like you find in C++, Python, and probably many others. Yes, I know there is `define-error` for a while, but we'd still be reinventing all those protocols in subtly idiosyncratic and buggy forms ad-hoc in Elisp. Which admittedly, is what we've been doing all along, but why stray gratuitously when given a (presumably cheap) chance to rejoin? Jo=C3=A3o [1]: https://github.com/joaotavora/snooze