Thread View: borland.public.cppbuilder.nativeapi
5 messages
5 total messages
Started by Sam S. Firouz
Fri, 25 Apr 2003 19:36
try, __finally
Author: Sam S. Firouz
Date: Fri, 25 Apr 2003 19:36
Date: Fri, 25 Apr 2003 19:36
25 lines
1494 bytes
1494 bytes
Hi:
According to the help file, "The __finally keyword specifies actions that
should be taken regardless of how the flow within the preceding __try
exits.". But in the example below the __finally block will not execute if we
get to return statement. Any ideas? Could this be a builder bug?
if the return is within the first try and not the nested one it works fine.
I have tried this in BCB5 Ent. and BCB6 Ent.
try
{
try
{
/* Do something */
if (/* some condition */)
return;
/* Do something */
}
catch (...)
{
/* Do something */
}
}
__finally
{
/* Do something */
}
Re: try, __finally
Author: Martin Stainsby
Date: Fri, 25 Apr 2003 20:59
Date: Fri, 25 Apr 2003 20:59
38 lines
1677 bytes
1677 bytes
"Sam S. Firouz" <sfirouz@Hotmail.com> wrote in message
news:3ea98e27@newsgroups.borland.com...
> Hi:
> try
> {
> try
> {
> /* Do something */
> if (/* some condition */)
> return;
> /* Do something */
> }
> catch (...)
> {
> /* Do something */
> }
> }
> __finally
> {
> /* Do something */
> }
>
>
Instead of testing for true and returning , why not test for false and
execute /* Do something */ then let the function return itself.
instead of this
if (/* some condition */)
return;
/* Do something */
try this
if (/* !some condition */)
/* Do something */
Re: try, __finally
Author: Sam S. Firouz
Date: Fri, 25 Apr 2003 21:23
Date: Fri, 25 Apr 2003 21:23
51 lines
1937 bytes
1937 bytes
I knew the workaround. I was just wondering if this is by design or a
compiler bug.
Sam
"Martin Stainsby" <mstainsbyN0@SPAMntlworld.com> wrote in message
news:3ea9a191@newsgroups.borland.com...
>
> "Sam S. Firouz" <sfirouz@Hotmail.com> wrote in message
> news:3ea98e27@newsgroups.borland.com...
> > Hi:
>
> > try
> > {
> > try
> > {
> > /* Do something */
> > if (/* some condition */)
> > return;
> > /* Do something */
> > }
> > catch (...)
> > {
> > /* Do something */
> > }
> > }
> > __finally
> > {
> > /* Do something */
> > }
> >
> >
>
> Instead of testing for true and returning , why not test for false and
> execute /* Do something */ then let the function return itself.
>
> instead of this
>
> if (/* some condition */)
> return;
> /* Do something */
>
> try this
> if (/* !some condition */)
> /* Do something */
>
>
>
>
Re: try, __finally
Author: Andrue Cope
Date: Sat, 26 Apr 2003 09:33
Date: Sat, 26 Apr 2003 09:33
18 lines
1507 bytes
1507 bytes
Sam S. Firouz, You would do better asking C++ language questions in the newsgroup section set aside for them. It's not hard to find as it's called LANGUAGE.CPP Borland newsgroups are described at: http://info.borland.com/newsgroups Guidelines: http://info.borland.com/newsgroups/guide.html Etiquette: http://info.borland.com/newsgroups/netiquette.html Andrue Cope [Bicester, UK]
Re: try, __finally
Author: Neil Duffee
Date: Mon, 05 May 2003 17:27
Date: Mon, 05 May 2003 17:27
26 lines
2065 bytes
2065 bytes
"Sam S. Firouz" wrote:
> According to the help file, "The __finally keyword specifies actions that
> should be taken regardless of how the flow within the preceding __try
> exits.". [snip]
> try
> {
> [snip]
> }
> __finally
> {
> /* Do something */
> }
Aside from the comment about .cpp.language, you might read your own post
a little more closely for a possible solution. The help file states
'__try' and your code has 'try'.
'course, this has likely been answered in the 2 intervening weeks in the
other newsgroup and I have *no* idea the difference 'tween the two types
of 'try' statements but...
----------> signature = 5 lines follows <--------------
Neil Duffee, Joe Systems Guy, U d'Ottawa, Ottawa, Ont, Canada
telephone:1 613 562 5800 x4585 fax:1 613 562 5161
mailto:NDuffee at uottawa.ca http://aix1.uottawa.ca/~nduffee
"How *do* you plan for something like that?" Guardian Bob, Reboot
"For every action, there is an equal and opposite criticism."
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads