Adi Stav wrote:
>On Tue, Jul 03, 2001 at 12:13:47AM +0300, Shaul Karl wrote:
>
>>Thank you for the responses.
>>What I have done wrong is already pointed out.
>>If you are curious what I am trying to do:
>>
>>1. I wanted to have jmp_buf* passed as a function parameter in order to avoid
>>a global variable. Therefore, in the function body I had to use a local
>>variable and initialize it with this pointer:
>> jmp_buf local_variable = *function_paramter;
>>
>
>You're using jmp_buf as an exception throwing mechanism. I'd say it WOULD
>make sense to have jmp_buf a global (or per-thread, yuck) variable, since
>exceptions are global by nature.
>
Are they????
short C++ code:
void A()
{
try
{
class someclass var1(constructor_arguments);
B();
some_more_activities();
} catch( ... )
{
some_exception_code();
}
}
void B()
{
class someotherclass var2( constructor_arguments );
...
C();
}
void C()
{
blah();
if( adi_stav_was_here==true )
throw NOOOOOOO(5);
}
If we try to (as CFront used to do) compile this code into C, we see
that the long jump triggered by the throw in function C must stop inside
function B, in order to run the var2 destructor. This catch handler can
then long jump to function A to handle the explicit catch handler.
Conclusion 1 - if you enable exception handling in C++, all your
functions probably carry exception handlers (there are good things to
say for Java's "you must declare exceptions" syntax).
Conclusion 2 - exceptions are not global, far from it.
For those of you still only programming in C, replace "destructor" with
"cleanup code".
Shachar
P.S.
I am not trying to say there is anything against Adi Stav being here. I
have nothing against Adi Stav in particular, and bearded people in
general. Some of my best friends are Adi Stav.
=================================================================
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]