From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Nic Ferrier Newsgroups: gmane.emacs.devel Subject: non-local exits with signal and condition-case Date: Sun, 02 Jun 2013 17:24:47 +0100 Message-ID: <87ip1wjx9s.fsf@ferrier.me.uk> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1370190305 15041 80.91.229.3 (2 Jun 2013 16:25:05 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 2 Jun 2013 16:25:05 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Jun 02 18:25:05 2013 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1UjB5Z-00086G-Ey for ged-emacs-devel@m.gmane.org; Sun, 02 Jun 2013 18:25:01 +0200 Original-Received: from localhost ([::1]:48613 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UjB5Y-0003I3-VJ for ged-emacs-devel@m.gmane.org; Sun, 02 Jun 2013 12:25:00 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:56451) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UjB5T-0003Hv-9w for emacs-devel@gnu.org; Sun, 02 Jun 2013 12:24:58 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UjB5Q-00072j-V3 for emacs-devel@gnu.org; Sun, 02 Jun 2013 12:24:55 -0400 Original-Received: from static.17.66.46.78.clients.your-server.de ([78.46.66.17]:38000 helo=po1.ferrier.me.uk) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UjB5Q-00072T-PS for emacs-devel@gnu.org; Sun, 02 Jun 2013 12:24:52 -0400 Original-Received: from nferrier (140.35.155.90.in-addr.arpa [90.155.35.140]) by po1.ferrier.me.uk (Postfix) with ESMTP id 489ACAC00A5; Sun, 2 Jun 2013 18:24:58 +0200 (CEST) Original-Received: from nferrier (localhost [127.0.0.1]) by nferrier (Postfix) with ESMTPS id E49921600B7; Sun, 2 Jun 2013 17:24:47 +0100 (BST) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 78.46.66.17 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 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.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:159989 Archived-At: Is it just me or is catch annoying for some non-local exits? When I do non-local exits, which isn't often, I mostly want to non-locally exit and pass some data back. Maybe this is the fault of my exposure to Java programming and using exceptions for flow control? Anyway. I find that catch rarely fulfils my needs. It's possible to use signal and condition-case to achieve the effect that I most often want and I do use them. But making new signals is slightly annoying because you need to add 2 different properties to a symbol. I propose a simple macro to make this easier: (defmacro defsignal (err-symbol inherits-list message) (let ((errv (make-symbol "err-v"))) `(let ((,errv ,err-symbol)) (put ,errv 'error-conditions (quote ,inherits-list)) (put ,errv 'error-message ,message)))) One uses it like this: (defsignal :nictest-blah (:nictest :nictest-blah) "blah!") I'm not sure where to put this. I could package it. But I'm collecting a list of these things (noflet, let-while, etc...) and gradually it seems I'm inventing my own lisp. This one though seems to be a genuine gap in elisp. Is there any interest in core-ing it? Nic