Re: Why do some code bases don't use exceptions?
Joshua Maurice wrote:
> On Dec 9, 1:44 am, "dragan" <spambus...@prodigy.net> wrote:
>> peter koch wrote:
>>> On 8 Dec., 22:15, "dragan" <spambus...@prodigy.net> wrote:
>>>> "Richard" <legalize+jee...@mail.xmission.com> wrote in message
>>
>>> [snip]
>>
>>>>> (setjmp/longjmp vs. C++
>>>>> exceptions), not the more advanced. C++ exceptions are in no way
>>>>> derived from setjmp.
>>
>>>> I disagree. The similarity is too uncanny to not be related. As C++
>>>> was designed to formalize and build upon existing C practices, it
>>>> makes sense.
>>
>>>>> setjmp/longjmp is essentially a non-local goto.
>>>>> It is not an exception, nor does it unwind the stack, it simply
>>>>> overwrites the stack pointer.
>>
>>>> No one was suggesting anything of the sort. I'll excuse your
>>>> miscomprehension of what I wrote only if English is not your
>>>> primary language. (Because I'm tired of all the childish antics in
>>>> programming forums).
>>
>>> I believe you told us that you had read "The Design and Evolution of
>>> C+ +" by Stroustrup. If that was the case, you'd be aware of the
>>> origin of the C++ exception mechanism. The origin is Ada, and the
>>> belief that a try-block executes anything similar to a setjmp or
>>> that a catch executes anything similar to a longjmp is misleading
>>> and wrong.
>>
>> The pattern is the same. No one suggested that the _mechanisms_ were
>> the same or even alike. "Jumping across levels" is jumping across
>> levels.
>
> They're not.
I didn't say 'they', I said 'the': the pattern defined as propagating across
levels as compared to propagating one activation record at a time. That is
THE key behavior of C++ exception machinery, hence the focus on that and
what I thought would have been obvious contextually given the topic (I guess
not!). Read the whole passage again and you will surely understand it as
what I reframed if you don't whittle out a portion of it and react only to
that portion.
> You have to manually jump back and forth with longjmp,
> that is at least a round trip to free resources. Exception handling is
> a one way trip. That's fundamentally different. Perhaps they both
> serve a similar purpose, but they "get there" in very different ways.
|