Re: efficient exception handling
On Oct 15, 2:44 pm, James Kanze <james.ka...@gmail.com> wrote:
> On Oct 15, 12:17 pm, Erik Wikström <Erik-wikst...@telia.com> wrote:
>
> > On 2007-10-15 09:44, terminator wrote:
>
> [...]
>
> > > I do not feel much doubt about the standardness of the above context ,
> > > but IMO the std could be more elegant with the some minor
> > > modifications;
> > To my knowledge the way exceptions work in C++ is very similar to the
> > way they work in other languages (though I do not claim to have
> > knowledge of all languages that support exceptions). I would assume that
> > this is not because the inventors of the other languages could not
> > imagine other ways to do things, but rather because it is the most sane
> > way of doing things.
>
> It depends on the time frame, I think. Resumable exceptions was
> a frequent feature in languages which implemented them before
> C++, I think. The reason C++, and other more recent languages,
> don't support it is a result of concrete experience with it in
> these other languages.
Maybe there existed no pratical idea to implement it at that
time .Edison failed to build the lamp thousands of times ,but at least
he learnt a thousant ways of not making lamps.
>
> > > i.It looks as if the stack unwinding is performed at
> > > 'throw' site .but IMHO if the stack unwinding is left to
> > > the 'catch' site the program will be more flexible;because
> > > it gives us the option to handle the trouble and resume the
> > > program from the statement after the throw ,rather than
> > > stopping what was performing before the throw.
> > If it was possible to handle the exception at the site where
> > it was thrown it should have been caught at the same place and
> > the problem fixed and no exception would have propagated in
> > the first place. The reason for an exception to be caught at
> > another site would be because that is to only logical place to
> > handle the exception.
>
> If it was possible to handle the error condition at the site
> where it was detected, one should do so, and not raise an
> exception to begin with.
>
> The usual argument for resumable exceptions is that the catch
> block will somehow "correct" the condition which caused the
> error, so you can resume. Of course, this doesn't work in
> practice, because by the time you catch the exception, you've
> generally done some things which would not have been done, or
> which would have been done differently in the new context.
>
what is context? can u describe more plz?
Is it another thread or a different stack segment or OS access level
or another computer or what?
thanks,
FM.
|