<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xml:base="http://www.newlc.com" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
 <title>NewLC - TRAPs and Leaves - Comments</title>
 <link>http://www.newlc.com/en/TRAPs-and-Leaves.html</link>
 <description>Comments for &quot;TRAPs and Leaves&quot;</description>
 <language>en</language>
<item>
 <title>&gt; TRAPs and Leaves</title>
 <link>http://www.newlc.com/en/TRAPs-and-Leaves.html#comment-169</link>
 <description>&lt;div class=&quot;spip-content&quot;&gt;Try Catch is not used in Symbian because of one more very important Reason, 
* It produces a lot of RAM overhead and also adds on considerably to the size of the compiled code.
   Thus The compilers are directed specifiaclly to Flag an error if C++ exeception handling is used.&lt;/div&gt;</description>
 <pubDate>Thu, 18 Jan 2007 03:50:53 +0100</pubDate>
 <dc:creator>Inder</dc:creator>
 <guid isPermaLink="false">comment 169 at http://www.newlc.com</guid>
</item>
<item>
 <title>how to execute the statement, when leave happens</title>
 <link>http://www.newlc.com/en/TRAPs-and-Leaves.html#comment-170</link>
 <description>&lt;div class=&quot;spip-content&quot;&gt;&lt;p class=&quot;spip&quot;&gt;You should use a trap harness to do this and rename your Exe() function to ExeL() to indicate it can leave (the latter won&#039;t change anything in how the code behaves but will give an indication to other users of your code).&lt;/p&gt;

&lt;p class=&quot;spip&quot;&gt;&lt;tt&gt;&lt;div align=&#039;left&#039; class=&#039;spip_code&#039; dir=&#039;ltr&#039;&gt;TInt res=KErrUnknown;&lt;br /&gt;
TRAPD(leaveCause, res=ptr-&amp;gt;ExeL());&lt;br /&gt;
if(res==(xxxx))&lt;br /&gt;
{ &lt;br /&gt;
 &amp;nbsp;// success&lt;br /&gt;
}&lt;br /&gt;
else&lt;br /&gt;
{&lt;br /&gt;
 // error&lt;br /&gt;
 // use res and leaveCause to get further information&lt;br /&gt;
}&lt;/div&gt;&lt;/tt&gt;&lt;/p&gt;&lt;/div&gt;</description>
 <pubDate>Tue, 19 Dec 2006 09:17:23 +0100</pubDate>
 <dc:creator>eric</dc:creator>
 <guid isPermaLink="false">comment 170 at http://www.newlc.com</guid>
</item>
<item>
 <title>how to execute the statement, when leave happens</title>
 <link>http://www.newlc.com/en/TRAPs-and-Leaves.html#comment-167</link>
 <description>&lt;div class=&quot;spip-content&quot;&gt;&lt;p class=&quot;spip&quot;&gt;Hi below is snap of code&lt;/p&gt;

&lt;p class=&quot;spip&quot;&gt;ptr-&gt;ExecutecodeL( xxx);
    if (ptr-&gt;Exe() == (xxx)
    &lt;i class=&quot;spip&quot;&gt;
    _LIT(&quot;success&quot;);
    &lt;/i&gt;
    else
    &lt;i class=&quot;spip&quot;&gt;
    _LIT(&quot;Error&quot;);
    &lt;/i&gt;&lt;/p&gt;

&lt;p class=&quot;spip&quot;&gt;when i execute function ptr-&gt;Exe() function will leave. so I want to execute statement &quot;_LIT(&quot;success&quot;);&quot; even if it leaves. How can i implement this.&lt;/p&gt;&lt;/div&gt;</description>
 <pubDate>Tue, 19 Dec 2006 06:16:43 +0100</pubDate>
 <dc:creator>pacuboit</dc:creator>
 <guid isPermaLink="false">comment 167 at http://www.newlc.com</guid>
</item>
<item>
 <title>&gt; like exceptions?</title>
 <link>http://www.newlc.com/en/TRAPs-and-Leaves.html#comment-166</link>
 <description>&lt;div class=&quot;spip-content&quot;&gt;&lt;p class=&quot;spip&quot;&gt;It is very similar to Exceptions.
The Symbian Leave and Trap pattern was established before C++ support for exceptions was finalised and correctly supported in gcc.&lt;/p&gt;

&lt;p class=&quot;spip&quot;&gt;Trap and leave are used for rolling back operations. And the rules of writing exception safe code apply equally to leaves. So brush up on the lessons of C++ gurus such as Herb sutter.&lt;/p&gt;

&lt;p class=&quot;spip&quot;&gt;leave do have limitations compared with exceptions.&lt;/p&gt;

&lt;p class=&quot;spip&quot;&gt;1. You can only leave with a TInt error code. exceptions can throw any kind of object, which offers the possiblity to throw more context.&lt;/p&gt;

&lt;p class=&quot;spip&quot;&gt;2. Destructors are not called
leaves are implemented in a similar way to long jumps which means that destructors of stack based objects will not be called as a result of an exception.
To get around this, the leave mechanism is complemented by the cleanup stack.
On leave, anything that needs to be destroyed in order to achive successful rollback (and freeing of resources) should be pushed on the cleanup stack.
The cleanup stack is a manager object and used in roughly the same way as TAutoPtr. See the link&lt;/p&gt;

&lt;p class=&quot;spip&quot;&gt;3. Leave safety is not enforced by the compiler. Ony a naming convention is used to denote the exception API.&lt;/p&gt;

&lt;p class=&quot;spip&quot;&gt;With the forthcoming support for EABI binary inferface and rich compilers, Symbian will need to move over to a more industry standard exception mechanism.&lt;/p&gt;&lt;/div&gt;</description>
 <pubDate>Tue, 02 Nov 2004 00:39:29 +0100</pubDate>
 <dc:creator>Mr Big</dc:creator>
 <guid isPermaLink="false">comment 166 at http://www.newlc.com</guid>
</item>
<item>
 <title>&gt; TRAPs and Leaves, here&#039;</title>
 <link>http://www.newlc.com/en/TRAPs-and-Leaves.html#comment-168</link>
 <description>&lt;div class=&quot;spip-content&quot;&gt;&lt;p class=&quot;spip&quot;&gt;No try-catch was available when Symbian was originally developed. AFAIK. (I read this from a magazine months ago.)&lt;/p&gt;

&lt;p class=&quot;spip&quot;&gt;And now that we have this nice TRAP thingy, and it is widely used, we don&#039;t even want to change to try-catch!&lt;/p&gt;&lt;/div&gt;</description>
 <pubDate>Tue, 01 Jun 2004 13:42:21 +0200</pubDate>
 <dc:creator>Anonymous</dc:creator>
 <guid isPermaLink="false">comment 168 at http://www.newlc.com</guid>
</item>
<item>
 <title>&gt; TRAPs and Leaves</title>
 <link>http://www.newlc.com/en/TRAPs-and-Leaves.html#comment-165</link>
 <description>&lt;div class=&quot;spip-content&quot;&gt;&lt;p class=&quot;spip&quot;&gt;void MyControl::Draw(const TRect&amp; aRect)  throw()
&lt;i class=&quot;spip&quot;&gt;
...
try&lt;i class=&quot;spip&quot;&gt;
    MyLeavingFunctionL());
&lt;/i&gt;catch(...)&lt;i class=&quot;spip&quot;&gt;
...
&lt;/i&gt;&lt;/p&gt;

&lt;p class=&quot;spip&quot;&gt;&lt;/i&gt;&lt;/p&gt;

&lt;p class=&quot;spip&quot;&gt;what is diff?&lt;/p&gt;&lt;/div&gt;</description>
 <pubDate>Thu, 13 May 2004 03:17:17 +0200</pubDate>
 <dc:creator>gg</dc:creator>
 <guid isPermaLink="false">comment 165 at http://www.newlc.com</guid>
</item>
<item>
 <title>&gt; TRAPs and Leaves</title>
 <link>http://www.newlc.com/en/TRAPs-and-Leaves.html#comment-164</link>
 <description>&lt;div class=&quot;spip-content&quot;&gt;why not try-catch?&lt;/div&gt;</description>
 <pubDate>Thu, 13 May 2004 03:12:06 +0200</pubDate>
 <dc:creator>gg</dc:creator>
 <guid isPermaLink="false">comment 164 at http://www.newlc.com</guid>
</item>
<item>
 <title>like exceptions?</title>
 <link>http://www.newlc.com/en/TRAPs-and-Leaves.html#comment-163</link>
 <description>&lt;div class=&quot;spip-content&quot;&gt;So this is very similar to try&lt;i class=&quot;spip&quot;&gt;&lt;/i&gt; and exception handling is it not? similarities? differences?&lt;/div&gt;</description>
 <pubDate>Sun, 07 Mar 2004 09:03:04 +0100</pubDate>
 <dc:creator>S Woodside</dc:creator>
 <guid isPermaLink="false">comment 163 at http://www.newlc.com</guid>
</item>
<item>
 <title>TRAPs and Leaves</title>
 <link>http://www.newlc.com/en/TRAPs-and-Leaves.html</link>
 <description>&lt;div class=&quot;spip-content&quot;&gt;&lt;/div&gt;&lt;p&gt;&lt;a href=&quot;http://www.newlc.com/en/TRAPs-and-Leaves.html&quot;&gt;read more&lt;/a&gt;&lt;/p&gt;</description>
 <comments>http://www.newlc.com/en/TRAPs-and-Leaves.html#comments</comments>
 <category domain="http://www.newlc.com/en/taxonomy/term/1">Basics</category>
 <category domain="http://www.newlc.com/en/taxonomy/term/125">Error Management</category>
 <category domain="http://www.newlc.com/en/taxonomy/term/137">Memory Management</category>
 <pubDate>Fri, 07 Mar 2003 14:50:03 +0100</pubDate>
 <dc:creator>eric</dc:creator>
 <guid isPermaLink="false">36 at http://www.newlc.com</guid>
</item>
</channel>
</rss>
