Article View: comp.std.c++
Article #713Re: Exception Specifications
From: Pablo Halpern
Date: Mon, 12 Oct 1992 16:44
Date: Mon, 12 Oct 1992 16:44
37 lines
2470 bytes
2470 bytes
In article <KANZE.92Oct7151332@slsvdnt.us-es.sel.de>, kanze@us-es.sel.de (James Kanze) writes: |> This leads to my basic premise. |> |> Objects in a general library should not throw exceptions at all. The |> how and what of exception handling is *always* application specific, |> and if a library like the iostream starts throwing exceptions, it |> forces *all* applications that use it into its mould. |> |> The solution I prefer is call-back functions. The default failure |> action is always to terminate the program with an error message. |> Since this occurs near the point of the error, the error message can |> actually be quite meaningful. In failsafe applications, the user |> replaces the default error function with one of his own, which may |> very well (probably will) throw an exception. This will be an |> exception designed by the user however, and not one imposed by the |> library. The choice of whether one or many exception classes, etc., |> and in what class hierarchy they are, can then be made in an |> application specific manner by the user. Sorry to waste bandwidth on such a short follow-up, but I just want to re-enforce James' premise and his call-back solution. Let the client of a general library choose what type of action to take for an error in a general-purpose library. Using this mechanism for the default allocator would allow a GUI-based application to automatically display an "Out of Memory" message and terminate, for example, rather than raise an exception. -- - Pablo ------------------------------------------------------------------------ Pablo Halpern (617) 290-3542 HP Waltham pabloh@hpwarq.wal.hp.com I am self-employed, so my opinions *do* reflect those of my employer. However, they may not reflect the opinions of my client. ------------------------------------------------------------------------
Technical Details
Message-ID:
<3791@hpwala.wal.hp.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!know!cass.ma02.bull.com!think.com!ames!elroy.jpl.nasa.gov!sdd.hp.com!scd.hp.com!hplextra!hpcss01!hpwala!pablohReferences:
<1992Sep29.201603.19289@cs.brown.edu> <1992Sep30.205656.10646@lucid.com> <1992Oct01.143355.27847@bnr.ca> <KANZE.92Oct7151332@slShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!know!cass.ma02.bull.com!think.com!ames!elroy.jpl.nasa.gov!sdd.hp.com!scd.hp.com!hplextra!hpcss01!hpwala!pabloh From: pabloh@hpwala.wal.hp.com (Pablo Halpern ) Newsgroups: comp.std.c++ Subject: Re: Exception Specifications Message-ID: <3791@hpwala.wal.hp.com> Date: 12 Oct 92 16:44:09 GMT References: <1992Sep29.201603.19289@cs.brown.edu> <1992Sep30.205656.10646@lucid.com> <1992Oct01.143355.27847@bnr.ca> <KANZE.92Oct7151332@sl Sender: netnews@hpwala.wal.hp.com Organization: Hewlett-Packard Company Lines: 37