[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]

Re: $^S and eval



Tom Christiansen wrote:

> >Fair enough. What, then, would be the most legitimate way of
> >(effectively) subclassing C<die> for a script?
> 
> C<die> is not a class, so I don't understand what "subclassing" it
> should mean.

I should have put "subclassing" in quotes - what I meant was "add some
functionality to die without having to reimplement the whole damned
thing".


> Do you mean, how do you catch an uncaught die?

Not particularly. I do so because I can (and because the stock C<die>
exit processing doesn't do anything sensible if handed an object
reference). I invariably wrap my scripts in C<eval {}> (or rather C<try
{} except {}>, but that's just syntactic sugar).

> Do you mean how do you replace the CORE die with your own function?
> That's done by importing into CORE::GLOBAL::die.

Probably. I've yet to find anything useful in the way of documentation
for this (certainly there seems to be nothing in either Camel or
Panther). Hey! give me enough hints to do it and I might even dig out an
odd tuit or two and write some proper docs.

> "Any attempt to build a general exception model on [$SIG{__DIE__}] should
> be politely squashed."

Mea culpa :)

Actually, I don't want to use C<$SIG{__DIE__}> at all; I've just been
forced to do so in order to get exception objects (OK, I /know/ they're
an "experimental" feature) to do anything remotely useful in real
scripts.

Pete
-- 
use Disclaimer::Standard;	# Motorola GSM Software Factory
my $phone='+44 1793 564450';	# "'Not twisted,' Salzy once said of
my $fax='+44 1793 566918';	#  her own passion, 'it is helical.
my $mobile='+44 7973 725120';	#  That sounds better.'"


References to:
Tom Christiansen <tchrist@chthon.perl.com>

[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]