From: "Pascal J. Bourguignon" <pjb@informatimago.com>
To: help-gnu-emacs@gnu.org
Subject: Re: About `catch' and `throw'
Date: Sat, 22 Dec 2012 21:33:54 +0100 [thread overview]
Message-ID: <87mwx5zv0t.fsf@kuiper.lan.informatimago.com> (raw)
In-Reply-To: mailman.15933.1356198906.855.help-gnu-emacs@gnu.org
Stefan Monnier <monnier@iro.umontreal.ca> writes:
>> During the evaluation of code that is lexically inside the `catch',
>> a `throw' that is evaluated throws back to that `catch'.
>
> Usually, but not always.
>
>> And if there is more than one `catch' with the same label then it
>> throws to the one that is lexically nearest (i.e., innermost, outside
>> the `throw'), which is also the most recent.
>
> Usually, but not always:
>
> (catch 'foo
> (let ((f (lambda () (throw 'foo))))
> ...
> (catch 'foo
> (funcall f))
> ...))
>
> will throw to the inner catch, not the outer one.
Again, because it does not matter WHERE the catch is: it's not because
it's _placed_ _inner_ or _outer_.
What matter is WHEN the catch is: it is because it is the most recently
established catch 'foo, that it will catch the throw 'foo. Conversely
with:
(catch 'foo
(funcall (catch 'foo
(lambda () (throw 'foo)))))
it is the first catch 'foo which is the most RECENTLY established catch
'foo, WHEN throw 'foo is called, because the second catch 'foo at that
TIME has been already disestablished.
--
__Pascal Bourguignon__ http://www.informatimago.com/
A bad day in () is better than a good day in {}.
next prev parent reply other threads:[~2012-12-22 20:33 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-21 12:00 About `catch' and `throw' Xue Fuqiao
2012-12-21 17:03 ` Drew Adams
2012-12-22 17:50 ` Stefan Monnier
[not found] ` <mailman.15933.1356198906.855.help-gnu-emacs@gnu.org>
2012-12-22 20:33 ` Pascal J. Bourguignon [this message]
2012-12-21 19:08 ` Pascal J. Bourguignon
[not found] ` <mailman.15880.1356116940.855.help-gnu-emacs@gnu.org>
2013-01-05 0:57 ` David Combs
2013-01-08 16:08 ` Stefan Monnier
[not found] ` <mailman.16939.1357661400.855.help-gnu-emacs@gnu.org>
2013-02-13 1:08 ` David Combs
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87mwx5zv0t.fsf@kuiper.lan.informatimago.com \
--to=pjb@informatimago.com \
--cc=help-gnu-emacs@gnu.org \
/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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).