From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: non-local exits with signal and condition-case Date: Sun, 02 Jun 2013 14:52:24 -0400 Message-ID: References: <87ip1wjx9s.fsf@ferrier.me.uk> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; CHARSET=US-ASCII Content-Transfer-Encoding: 7BIT X-Trace: ger.gmane.org 1370199153 826 80.91.229.3 (2 Jun 2013 18:52:33 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 2 Jun 2013 18:52:33 +0000 (UTC) Cc: emacs-devel@gnu.org To: Nic Ferrier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Jun 02 20:52:33 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 1UjDOJ-00044O-J4 for ged-emacs-devel@m.gmane.org; Sun, 02 Jun 2013 20:52:31 +0200 Original-Received: from localhost ([::1]:50894 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UjDOJ-0004N4-7X for ged-emacs-devel@m.gmane.org; Sun, 02 Jun 2013 14:52:31 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:56982) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UjDOF-0004AU-M9 for emacs-devel@gnu.org; Sun, 02 Jun 2013 14:52:28 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UjDOE-0004jf-0f for emacs-devel@gnu.org; Sun, 02 Jun 2013 14:52:27 -0400 Original-Received: from relais.videotron.ca ([24.201.245.36]:65044) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UjDOD-0004iv-SZ for emacs-devel@gnu.org; Sun, 02 Jun 2013 14:52:25 -0400 Original-Received: from ceviche.home ([184.163.196.74]) by VL-VM-MR004.ip.videotron.ca (Oracle Communications Messaging Exchange Server 7u4-22.01 64bit (built Apr 21 2011)) with ESMTP id <0MNS00A1U4FD1F90@VL-VM-MR004.ip.videotron.ca> for emacs-devel@gnu.org; Sun, 02 Jun 2013 14:52:25 -0400 (EDT) Original-Received: by ceviche.home (Postfix, from userid 20848) id CFDC266107; Sun, 02 Jun 2013 14:52:24 -0400 (EDT) In-reply-to: <87ip1wjx9s.fsf@ferrier.me.uk> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Solaris 10 X-Received-From: 24.201.245.36 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:160000 Archived-At: > 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. Could you explain in more detail what you do that doesn't work well with catch? > But making new signals is slightly annoying because you need to add 2 > different properties to a symbol. Using signals is clearly not a good idea if what you want is just a non-local exit. BTW, you might like the `cl-return' macro as well (to use within `cl-block's). > (defmacro defsignal (err-symbol inherits-list message) > (let ((errv (make-symbol "err-v"))) > `(let ((,errv ,err-symbol)) > (put ,errv > 'error-conditions > (quote ,inherits-list)) You probably want to cons `errv' in front of inherits-list. > (put ,errv > 'error-message > ,message)))) FWIW, I wouldn't mind introducing such a macro. Not for the use of non-local exits, but to make it easier to define new error conditions. I would also welcome changes to make the "error-message" part more flexible (e.g. be able to use a function, maybe). > I'm not sure where to put this. We could add it to subr.el (tho I'd call it define-signal). Stefan