Traps for module writers [was: Re: anonymous proxy server in 100
Nick Ing-Simmons (nik@tiuk.ti.com)
Tue, 26 Nov 1996 08:32:17 GMT
Gisle Aas <aas@bergen.sn.no> writes:
>Randal Schwartz <merlyn@stonehenge.com> writes:
>> A properly written library is going to have to have:
>>
>> eval {
>> local($SIG{__DIE__});
>> ...;
>> }
>>
>> and if you *don't* have that, *you* are asking for trouble, since the
>> user is free to write whatever they want as a die handler.
>
>Yes, it is probably easier to do it like this than to tell people not
>to use $SIG{__DIE__} :-(
>
>Perhaps we could have a "catch" keyword which worked like "eval" but
>localized $SIG{__DIE__} automatically?
>
Don't need a keyword - we can use a prototype - wrote this for Tk
yesterday in light of this thread here :
# a wrapper on eval {} which turns off user $SIG{__DIE__}
sub catch (&)
{
my $sub = shift;
eval {local $SIG{'__DIE__'}; &$sub };
}