develooper Front page | perl.perl5.porters | Postings from June 2004

Re: [perl #29851] Problem with Carp and Safe

Thread Next
From:
Lionel CONS
Date:
June 1, 2004 03:48
Subject:
Re: [perl #29851] Problem with Carp and Safe
Message ID:
16572.14035.186448.21538@mercury.cern.ch
Dave Mitchell via RT writes:
 > 
 > Carp will sometimes do:
 > 
 >     { local $@; require Carp::Heavy; }
 > 
 > Since require isn't allowed within the compartment, Perl raises an exception;
 > control is unwound to the eval done by the Safe::reval, then all the saved
 > stuff like the local()s are unwound, thus blowing away the error message
 > in $@.

Thanks for the explanation. I hope that this will get fixed in a
future version of the Carp module.

However, rather than forcing the user to add "require Carp::Heavy" in
user scripts before being able to use carp() inside Safe, I would prefer
another solution. The main reason being that users may not even know
that carp() is used inside Safe (it may be buried way down in the code).
Another reason is the messing up of $@ (cf. the "XXX fix require to
not clear $@?" comment in the current Carp module).

What about having Carp doing all the work in a proper way (e.g. not
messing around with $@), just like it was before (e.g. for Perl 5.5)
and provding a Carp::Light with dirty autoload tricks for people who
care about startup time? I prefer a clean default Carp module and a
dirty one for people who really need optimisation...

Cheers,
__________________________________________________________
Lionel Cons        http://cern.ch/lionel.cons
CERN               http://www.cern.ch

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About