all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Nic Ferrier <nferrier@ferrier.me.uk>
Cc: emacs-devel@gnu.org
Subject: Re: non-local exits with signal and condition-case
Date: Sun, 02 Jun 2013 14:52:24 -0400	[thread overview]
Message-ID: <jwvfvx0icds.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <87ip1wjx9s.fsf@ferrier.me.uk>

> 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	other threads:[~2013-06-02 18:52 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-02 16:24 non-local exits with signal and condition-case Nic Ferrier
2013-06-02 18:52 ` Stefan Monnier [this message]
2013-06-02 21:33   ` Nic Ferrier
2013-06-03  0:02     ` Stefan Monnier
2013-06-03 15:54     ` Davis Herring

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvfvx0icds.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=emacs-devel@gnu.org \
    --cc=nferrier@ferrier.me.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.