all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* non-local exits with signal and condition-case
@ 2013-06-02 16:24 Nic Ferrier
  2013-06-02 18:52 ` Stefan Monnier
  0 siblings, 1 reply; 5+ messages in thread
From: Nic Ferrier @ 2013-06-02 16:24 UTC (permalink / raw)
  To: emacs-devel

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



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-06-03 15:54 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-02 16:24 non-local exits with signal and condition-case Nic Ferrier
2013-06-02 18:52 ` Stefan Monnier
2013-06-02 21:33   ` Nic Ferrier
2013-06-03  0:02     ` Stefan Monnier
2013-06-03 15:54     ` Davis Herring

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.