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

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

Thread Previous | Thread Next
Nick Ing-Simmons
June 2, 2004 05:30
Re: [perl #29851] Problem with Carp and Safe
Message ID:
Lionel CONS <> writes:
>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).

The obvious "fix" here is to have do a 'require Carp::Heavy;'.

>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...

But Carp is mainly use-d by modules from CPAN and elsewhere.
There is thus a large installed base for the current interface.

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About