473,480 Members | 1,789 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Arguments for not using throw()

Hi all,

Since last summer, my group has been putting throw() into the code base
as a general guideline where applicable. I've disliked it from the
beginning, since I see it as a micro-optimization at the cost of no
stack unwinding (possible data corruption) when an exception is thrown
somewhere anyway, despite the best beliefs of the programmer adding the
throw().

Now I've determined to take up the discussion for real to get rid of
the throw() and I thought I pass this ball to you gentlemen:

What are the best arguments _against_ throw(), and for the sake of
completeness _for_ throw().

I know my Sutter and Meyers (et least their views on this issue), but
do you all have something to add to their input? I'd like to be well
prepared, so I can persuade those that have no strong opinion in either
direction, and perhaps even the originator of the idea...

Jul 23 '05 #1
2 1556
I maybe should have added that we don't even implement a terminate
handler for the case when a throw() function throws...

Jul 23 '05 #2
Johann Gerell wrote:
Hi all,

Since last summer, my group has been putting throw() into the code base
as a general guideline where applicable. I've disliked it from the
beginning, since I see it as a micro-optimization at the cost of no
stack unwinding (possible data corruption) when an exception is thrown
somewhere anyway, despite the best beliefs of the programmer adding the
throw().

Now I've determined to take up the discussion for real to get rid of
the throw() and I thought I pass this ball to you gentlemen:

What are the best arguments _against_ throw(), and for the sake of
completeness _for_ throw().

I know my Sutter and Meyers (et least their views on this issue), but
do you all have something to add to their input? I'd like to be well
prepared, so I can persuade those that have no strong opinion in either
direction, and perhaps even the originator of the idea...


You might check out Boost's rational for not using exception specifications:
http://www.boost.org/more/lib_guide....-specification

To paraphrase, smart compilers will realize when a function cannot
throw, and will do all the same optimizations as if you'd added throw().
Dumb compilers will often make pessimizations such as turning off
inlining or adding try/catch blocks.

-Alan
Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

46
2411
by: Leo Breebaart | last post by:
I've tried Googling for this, but practically all discussions on str.join() focus on the yuck-ugly-shouldn't-it-be-a-list-method? issue, which is not my problem/question at all. What I can't...
2
1635
by: Kevin Grigorenko | last post by:
Hello, I've been using Visual Studio.NET for some time, and I had this definition of a function in a class: void throwIt(int id, ErrorType type, ...) throw(...); I am trying to port my code...
28
2159
by: Scott Brady Drummonds | last post by:
Hi, all, I just got out of a meeting with a team of software developers that I recently joined as they are staffing to create a medium-sized project (potentially all of which will be written in...
1
4274
by: grandeandy | last post by:
question: in the code below, and in general, how would I input multiple functions into the code, and get multiple outputs? basically, I want to be able to add say 2 or 3 of the div's to the link so...
15
4196
by: Pohihihi | last post by:
This might sound little stupid to many but I was thinking that when we can use object why we really need event args to pass in any functions e.g. bool MyFunction(object sender, System.EventArgs...
10
28574
by: Andrew Bullock | last post by:
Hi, code: myClass x = new myClass(); x.dosomethingwith(x,y); How do i make dosomethingwith(x,y) run on a separate thread, and then inform the main thread when it has finished?
6
7449
by: Programador | last post by:
I'm getting this error when running this program: Cannot calculate rate using the arguments provided Module Module1 Sub Main() Rate(360, -694.44444444444446, 244274.69178082192) End Sub
16
2293
by: Martin Jørgensen | last post by:
Hi, Problem: ======== Some of my output functions are beginning to take pretty many arguments... I mean.... We're talking about 10-15 arguments :-) So I thought to myself, perhaps this is...
6
1555
by: shana07 | last post by:
Friends, I wish to consult about this big arithmetic program. This program basically is calculating big numbers. It work great from command prompt, for instance: java bigal 99999999999999999 + 5....
0
7044
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6908
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7045
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
6944
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
4782
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
2995
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
2985
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
563
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
182
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.