<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Exception Destruction</title>
	<atom:link href="http://www.airs.com/blog/archives/257/feed" rel="self" type="application/rss+xml" />
	<link>http://www.airs.com/blog/archives/257</link>
	<description>Ian Lance Taylor</description>
	<lastBuildDate>Sun, 07 Mar 2010 17:12:02 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Ian Lance Taylor</title>
		<link>http://www.airs.com/blog/archives/257/comment-page-1#comment-14957</link>
		<dc:creator>Ian Lance Taylor</dc:creator>
		<pubDate>Tue, 21 Oct 2008 05:44:58 +0000</pubDate>
		<guid isPermaLink="false">http://www.airs.com/blog/archives/257#comment-14957</guid>
		<description>Alan: it is of course possible to implement error handling with single cleanup using goto.  Lots of C code is written that way.  In a language which doesn&#039;t have exceptions, try/finally is just syntactic sugar: useful but not essential.

ncm: it&#039;s not the destructors which prevent moving instructions across function calls.  It&#039;s the fact that you can&#039;t move an instruction from one exception region to another.  That is, when using exceptions, all constructors and destructors must be completely run before or after a function call.  It is impossible to spread the instructions for a constructor or destructor across a function call, because you will be in an inconsistent state if an exception is thrown.

Cleanup functions aren&#039;t any better, I just threw that in as a comment.

You&#039;re right, in some cases you will win because of skipping the error checks.  In code like gold, I wouldn&#039;t, because I don&#039;t need to do error checks.  I can just crash if something goes badly wrong.</description>
		<content:encoded><![CDATA[<p>Alan: it is of course possible to implement error handling with single cleanup using goto.  Lots of C code is written that way.  In a language which doesn&#8217;t have exceptions, try/finally is just syntactic sugar: useful but not essential.</p>
<p>ncm: it&#8217;s not the destructors which prevent moving instructions across function calls.  It&#8217;s the fact that you can&#8217;t move an instruction from one exception region to another.  That is, when using exceptions, all constructors and destructors must be completely run before or after a function call.  It is impossible to spread the instructions for a constructor or destructor across a function call, because you will be in an inconsistent state if an exception is thrown.</p>
<p>Cleanup functions aren&#8217;t any better, I just threw that in as a comment.</p>
<p>You&#8217;re right, in some cases you will win because of skipping the error checks.  In code like gold, I wouldn&#8217;t, because I don&#8217;t need to do error checks.  I can just crash if something goes badly wrong.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ncm</title>
		<link>http://www.airs.com/blog/archives/257/comment-page-1#comment-14943</link>
		<dc:creator>ncm</dc:creator>
		<pubDate>Sun, 19 Oct 2008 07:51:50 +0000</pubDate>
		<guid isPermaLink="false">http://www.airs.com/blog/archives/257#comment-14943</guid>
		<description>I&#039;ve read and re-read this posting, and it seems about equally nuts (but in slightly varying ways, according to emphasis) each time.  Maybe I don&#039;t understand what instructions the compiler might (otherwise) move across which function calls, but can&#039;t because of destructors, and how that would have much effect on performance.  Aren&#039;t the destructors that run in performance critical code inline, anyway, and subject to aggressive optimization?  How are cleanup functions better, this way?

The measurements I&#039;ve heard of showed exception-using code substantially faster because many error checks after function calls could be deleted outright.</description>
		<content:encoded><![CDATA[<p>I&#8217;ve read and re-read this posting, and it seems about equally nuts (but in slightly varying ways, according to emphasis) each time.  Maybe I don&#8217;t understand what instructions the compiler might (otherwise) move across which function calls, but can&#8217;t because of destructors, and how that would have much effect on performance.  Aren&#8217;t the destructors that run in performance critical code inline, anyway, and subject to aggressive optimization?  How are cleanup functions better, this way?</p>
<p>The measurements I&#8217;ve heard of showed exception-using code substantially faster because many error checks after function calls could be deleted outright.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alan Stokes</title>
		<link>http://www.airs.com/blog/archives/257/comment-page-1#comment-14922</link>
		<dc:creator>Alan Stokes</dc:creator>
		<pubDate>Thu, 16 Oct 2008 10:15:10 +0000</pubDate>
		<guid isPermaLink="false">http://www.airs.com/blog/archives/257#comment-14922</guid>
		<description>Languages that support *error handling* need to support destructors or they need to support a try/finally construct.

Being able to specify cleanup just once is important, but is orthogonal to whether you signal an error via an exception or returning an error code.</description>
		<content:encoded><![CDATA[<p>Languages that support *error handling* need to support destructors or they need to support a try/finally construct.</p>
<p>Being able to specify cleanup just once is important, but is orthogonal to whether you signal an error via an exception or returning an error code.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ian Lance Taylor</title>
		<link>http://www.airs.com/blog/archives/257/comment-page-1#comment-14920</link>
		<dc:creator>Ian Lance Taylor</dc:creator>
		<pubDate>Thu, 16 Oct 2008 05:01:32 +0000</pubDate>
		<guid isPermaLink="false">http://www.airs.com/blog/archives/257#comment-14920</guid>
		<description>The cleanup functions are called in the reverse of the order of declaration.

In effect each variable with a cleanup attribute implicitly introduces a new try/finally scope.  Everything which follows the declaration of the variable is in the try block, and the cleanup function is in the finally clause.</description>
		<content:encoded><![CDATA[<p>The cleanup functions are called in the reverse of the order of declaration.</p>
<p>In effect each variable with a cleanup attribute implicitly introduces a new try/finally scope.  Everything which follows the declaration of the variable is in the try block, and the cleanup function is in the finally clause.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: gps</title>
		<link>http://www.airs.com/blog/archives/257/comment-page-1#comment-14919</link>
		<dc:creator>gps</dc:creator>
		<pubDate>Thu, 16 Oct 2008 04:55:57 +0000</pubDate>
		<guid isPermaLink="false">http://www.airs.com/blog/archives/257#comment-14919</guid>
		<description>Looking the gcc cleanup variable attribute up I find this documentation:

  http://gcc.gnu.org/onlinedocs/gcc/Variable-Attributes.html#Variable-Attributes

It doesn&#039;t answer one important question:

When multiple variables in one scope have a cleanup function, what order are the cleanup functions called in?</description>
		<content:encoded><![CDATA[<p>Looking the gcc cleanup variable attribute up I find this documentation:</p>
<p>  <a href="http://gcc.gnu.org/onlinedocs/gcc/Variable-Attributes.html#Variable-Attributes" rel="nofollow">http://gcc.gnu.org/onlinedocs/gcc/Variable-Attributes.html#Variable-Attributes</a></p>
<p>It doesn&#8217;t answer one important question:</p>
<p>When multiple variables in one scope have a cleanup function, what order are the cleanup functions called in?</p>
]]></content:encoded>
	</item>
</channel>
</rss>
