Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.programming > #2242
| From | Daniel Pitts <newsgroup.nospam@virtualinfinity.net> |
|---|---|
| Newsgroups | comp.programming |
| Subject | Re: etiology of exceptions |
| References | <d4aa81c8-9fb6-4251-a065-e3573eccce62@googlegroups.com> |
| Message-ID | <pMk8s.2721$QI.2130@newsfe16.iad> (permalink) |
| Date | 2012-09-25 09:15 -0700 |
On 9/25/12 7:29 AM, bob wrote: > What is the etiology of exceptions? Did they come about because people got tired of having to check a return value every time they called a function? > I don't know of how they came to be, but I can list several benefits. 1. The Error Condition and the Error Handler which-could-handle-it were often separated by several levels of calls. 2. Having a "magic" return value isn't always possible, or desirable, so some other mechanism needed to be employed. Passing an argument by reference has additional overhead for a hopefully rare case. 3. In some languages, Exceptions can be compile-time checked, which helps reduce the number of bugs. The compiler can even use its typing system to ensure that the *correct* exceptions are handled, further reducing human error. 4. Exceptions also allow easy polymorphism of error cases. Because of this, they are useful in more OO design patterns over simple return values. 5. In complicated programs, it is easier to visualize flow of execution with fewer "if" statements. Using exceptions allows easier understanding of the "normal" flow vs "exceptional" flow. It also helps to understand what code is actually responsible for handling error conditions (since its concentrated in the catch blocks). This is all just off the top of my head, and some of it may be arguable, but IMHO the argument that you can just check return values is flawed. You *can* just check return values, just as you *can* turn off a light-bulb by unscrewing it. There just is a better way.
Back to comp.programming | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
etiology of exceptions bob <bob@coolfone.comze.com> - 2012-09-25 07:29 -0700
Re: etiology of exceptions Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2012-09-25 09:15 -0700
Re: etiology of exceptions "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> - 2012-09-25 18:50 +0200
Re: etiology of exceptions Willem <willem@turtle.stack.nl> - 2012-09-25 20:51 +0000
Re: etiology of exceptions Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2012-09-25 15:32 -0700
Re: etiology of exceptions James Dow Allen <jdallen2000@yahoo.com> - 2012-09-25 23:43 -0700
Re: etiology of exceptions "Chris Uppal" <chris.uppal@metagnostic.REMOVE-THIS.org> - 2012-09-28 08:07 +0100
Re: etiology of exceptions Rui Maciel <rui.maciel@gmail.com> - 2012-09-28 09:47 +0100
Re: etiology of exceptions jussi.santti@ard.fi - 2012-10-07 23:13 -0700
Re: etiology of exceptions "LudovicoVan" <julio@diegidio.name> - 2012-10-08 22:37 +0100
Re: etiology of exceptions Ian Collins <ian-news@hotmail.com> - 2012-10-09 10:46 +1300
Re: etiology of exceptions "LudovicoVan" <julio@diegidio.name> - 2012-10-08 22:52 +0100
Re: etiology of exceptions Nick Keighley <nick_keighley_nospam@hotmail.com> - 2012-10-10 08:06 -0700
Re: etiology of exceptions "LudovicoVan" <julio@diegidio.name> - 2012-10-10 18:24 +0100
Re: etiology of exceptions Nick Keighley <nick_keighley_nospam@hotmail.com> - 2012-10-11 05:35 -0700
Re: etiology of exceptions "LudovicoVan" <julio@diegidio.name> - 2012-10-11 14:40 +0100
Re: etiology of exceptions Nick Keighley <nick_keighley_nospam@hotmail.com> - 2012-10-11 08:20 -0700
Re: etiology of exceptions jussi.santti@ard.fi - 2012-10-15 08:28 -0700
Re: etiology of exceptions "LudovicoVan" <julio@diegidio.name> - 2012-10-15 22:13 +0100
Re: etiology of exceptions Rui Maciel <rui.maciel@gmail.com> - 2012-10-11 15:35 +0100
Re: etiology of exceptions Nick Keighley <nick_keighley_nospam@hotmail.com> - 2012-10-11 08:21 -0700
Re: etiology of exceptions jussi.santti@ard.fi - 2012-10-15 08:10 -0700
Re: etiology of exceptions "LudovicoVan" <julio@diegidio.name> - 2012-10-15 22:16 +0100
csiph-web