From: Kris Warkentin <kewarken@qnx.com>
To: Andrew Cagney <ac131313@redhat.com>
Cc: gdb@sources.redhat.com
Subject: Re: TRY_CATCH()
Date: Thu, 13 Jan 2005 19:48:00 -0000 [thread overview]
Message-ID: <41E6D165.9010102@qnx.com> (raw)
In-Reply-To: <41E5BBE0.8000604@redhat.com>
Andrew Cagney wrote:
>PS: I recall this being proposed years ago, but the mechanism proposed
>at the time had a more cumbersom syntax, from memory something like:
>
> TRY_BEGIN
> ... do stuff ...
> TRY_END;
>
>
I saw something similar to this that worked really well but was not
quite as generic. Basically you would have to add a 'TryStack' member
to whatever data structure you were planning to capture exceptions on.
The TryStack was a stack of jmp_bufs. Then you'd do something like
if((error = TRY(mystruct)) == 0){
do_stuff(mystruct);
TRY_END(mystruct->try_stack);
}
else{
CATCH(mystruct, error);
handle_error();
}
The TRY would push a new jmp_buf onto the TryStack and the TRY_END and
CATCH would pop one. The various macros would be like #define TRY(foo)
is try_push(foo->try_stack) and so on. It's actually quite clever: If
something THROWs, it also pops but CATCH only pops if the error value is
zero so that you can have multiple tries and catches on a single block.
Anyway, interesting stuff.
cheers,
Kris
next prev parent reply other threads:[~2005-01-13 19:48 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-01-13 0:09 TRY_CATCH() Andrew Cagney
2005-01-13 19:48 ` Kris Warkentin [this message]
2005-01-14 19:29 ` TRY_CATCH() Frank Ch. Eigler
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=41E6D165.9010102@qnx.com \
--to=kewarken@qnx.com \
--cc=ac131313@redhat.com \
--cc=gdb@sources.redhat.com \
/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