From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3236 invoked by alias); 21 Mar 2008 02:45:21 -0000 Received: (qmail 3222 invoked by uid 22791); 21 Mar 2008 02:45:19 -0000 X-Spam-Check-By: sourceware.org Received: from wx-out-0506.google.com (HELO wx-out-0506.google.com) (66.249.82.225) by sourceware.org (qpsmtpd/0.31) with ESMTP; Fri, 21 Mar 2008 02:45:02 +0000 Received: by wx-out-0506.google.com with SMTP id s18so1352763wxc.14 for ; Thu, 20 Mar 2008 19:45:00 -0700 (PDT) Received: by 10.114.158.1 with SMTP id g1mr4915987wae.111.1206067499291; Thu, 20 Mar 2008 19:44:59 -0700 (PDT) Received: by 10.114.120.5 with HTTP; Thu, 20 Mar 2008 19:44:59 -0700 (PDT) Message-ID: Date: Fri, 21 Mar 2008 02:45:00 -0000 From: "Jason Cipriani" To: me22 Subject: Re: try, finally Cc: gcc-help@gcc.gnu.org In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: X-IsSubscribed: yes Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org X-SW-Source: 2008-03/txt/msg00211.txt.bz2 On Thu, Mar 20, 2008 at 10:36 PM, me22 wrote: > On Thu, Mar 20, 2008 at 10:10 PM, Jason Cipriani > > wrote: > > > On Thu, Mar 20, 2008 at 8:23 AM, John Love-Jensen wrote: > > > In my projects, throwing an exception mean "the application is about to > > > terminate." > > > > > > That's using the exception mechanism at the extreme of conservative > > > programming with exceptions. > > > > > > Assuming you use exceptions with less draconian policy, the exception > > > mechanism is not for using as normal flow control. It really means an > > > exceptional situation, outside of the normal flow control. > > > > > > For normal flow control -- such as handling predictable, common error > > > conditions -- you should use return codes. > > > > It seems that the root of any disagreement is what kinds of errors > > we'd prefer to represent with exceptions. You and Ted would use them > > for rare, fatal error conditions, similar in spirit to machine > > exceptions such as access violations and invalid instructions. I would > > use them for more common errors such as invalid user input, missing > > files, network errors, etc. I have a hunch nobody is going to be > > having a change of heart any time soon. :-) One thing that I have > > often noticed, incidentally, is that the longer a programmer has been > > programming before C++, the more they prefer error codes to > > exceptions. > > > > Personally, I think that if something can't happen, like a divide by > zero, is a case for an assert, not an exception. Leave them in the > release if you want, but better, fix them! > > I prefer using exceptions for things that you'd rather never happened, > and if everything does perfectly, never will happen. (Which also > means that their performance doesn't matter.) Especially when those > are the kinds of things that can rarely be handled locally. I like > having a fairly clean code path. > > Also, exceptions thrown in constructors mean tighter invariants that > you just can't get with return codes. 2-phase construction is evil. > > > [snip exceptionally long post that I didn't actually read, sorry :P ] That's OK :-) I don't think I actually read it, either! I did actually specifically mention that throwing exceptions from constructors leads to tighter invariants. I think you pretty much said everything I said in that last post, but a lot more efficiently. Jason > > >