From: bert hubert <ahu@ds9a.nl>
To: Larry McVoy <lm@work.bitmover.com>, Dan Aloni <da-x@gmx.net>,
linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: [RFC] [PATCH] C exceptions in kernel
Date: Sat, 23 Feb 2002 18:07:25 +0100 [thread overview]
Message-ID: <20020223180725.A3030@outpost.ds9a.nl> (raw)
In-Reply-To: <1014412325.1074.36.camel@callisto.yi.org> <20020223162100.A1952@outpost.ds9a.nl> <1014480355.1844.16.camel@callisto.yi.org> <20020223082211.Z11156@work.bitmover.com>
In-Reply-To: <20020223082211.Z11156@work.bitmover.com>; from lm@bitmover.com on Sat, Feb 23, 2002 at 08:22:11AM -0800
On Sat, Feb 23, 2002 at 08:22:11AM -0800, Larry McVoy wrote:
> On Sat, Feb 23, 2002 at 06:05:48PM +0200, Dan Aloni wrote:
> > But, it CAN be used in *local* driver call branches. Writing a new
> > driver? have a lot of local nested calls? Hate goto's? You can use
> > exceptions.
>
> Is this really anything other than syntactic sugar? Maybe it's different
> in drivers, but I find myself doing the following in user space all the time
Exceptions provide implicit handling. You should see tham as an alternate
return path. And because of that implicitness, it is not syntactic sugar.
However, one thing which your example does emphasize, it the risk of
resource leaks. Bjarne Stroustrup, who is no mean architect himself, spends
a lot of pages discussing those leaks.
Basically, an exception may fall through several functions before being
caught. Any resources acquired by those intermediate functions will not be
released unless this is done automatically during stack unwinding, ie,
destroctors or alloca(3).
So while having an alternate return path is cool, it really needs
destructors in order to be useful in a real world.
This url documents the problem, which is solved by adopting the 'Resource
Acquisition is Initialization' paradigm:
http://sourceforge.net/docman/display_doc.php?docid=8673&group_id=9028
Regards,
bert
--
http://www.tk the dot in .tk
Netherlabs BV / Rent-a-Nerd.nl - Nerd Available -
Linux Advanced Routing & Traffic Control: http://ds9a.nl/lartc
next prev parent reply other threads:[~2002-02-23 17:07 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-02-22 21:12 [RFC] [PATCH] C exceptions in kernel Dan Aloni
2002-02-22 21:28 ` Davide Libenzi
2002-02-22 22:10 ` Richard B. Johnson
2002-02-22 22:34 ` David B. Stevens
2002-02-22 22:48 ` Davide Libenzi
2002-02-23 3:37 ` Edgar Toernig
[not found] ` <mailman.1014437101.26721.linux-kernel2news@redhat.com>
2002-02-23 10:11 ` Pete Zaitcev
2002-02-23 12:26 ` Keith Owens
2002-02-23 12:50 ` Pete Zaitcev
2002-02-23 23:07 ` Jes Sorensen
2002-02-23 23:40 ` Keith Owens
2002-02-24 1:02 ` Jes Sorensen
2002-02-24 23:45 ` Richard Gooch
2002-02-23 23:50 ` Bill Huey
2002-02-24 1:31 ` Davide Libenzi
2002-02-24 2:55 ` Bill Huey
2002-02-23 15:13 ` Felix von Leitner
2002-02-23 15:21 ` bert hubert
2002-02-23 16:05 ` Dan Aloni
2002-02-23 16:22 ` Larry McVoy
2002-02-23 17:00 ` Dan Aloni
2002-02-23 17:52 ` Francois Romieu
2002-02-23 17:07 ` bert hubert [this message]
2002-02-23 17:47 ` Alexander Viro
2002-02-23 18:21 ` bert hubert
2002-02-23 18:31 ` Larry McVoy
2002-02-23 18:38 ` bert hubert
2002-02-23 19:12 ` Kurt Ferreira
2002-02-23 23:05 ` Jes Sorensen
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=20020223180725.A3030@outpost.ds9a.nl \
--to=ahu@ds9a.nl \
--cc=da-x@gmx.net \
--cc=linux-kernel@vger.kernel.org \
--cc=lm@work.bitmover.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