[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: (main_buf = *main_buf_p) is not syntacticly like (i = *j) ?
- To: Adi Stav <stav(at-nospam)actcom.co.il>
- Subject: Re: (main_buf = *main_buf_p) is not syntacticly like (i = *j) ?
- From: Shachar Shemesh <sun(at-nospam)consumer.org.il>
- Date: Tue, 03 Jul 2001 15:10:05 +0200
- CC: Shaul Karl <shaulka(at-nospam)bezeqint.net>, linux-il(at-nospam)linux.org.il
- Delivered-To: linux.org.il-linux-il@linux.org.il
- References: <E15HB0v-0003T6-00@rakefet> <20010703231655.C1398@wilma.stav>
- Sender: linux-il-bounce(at-nospam)cs.huji.ac.il
- User-Agent: Mozilla/5.0 (Windows; U; WinNT4.0; en-US; rv:0.9.2) Gecko/20010628
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 linux-il-request@linux.org.il with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail linux-il-request@linux.org.il