emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: non-local exits with signal and condition-case


From: Stefan Monnier
Subject: Re: non-local exits with signal and condition-case
Date: Sun, 02 Jun 2013 14:52:24 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)

> 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]