evalEmpire / perl5i

A single module to fix as much of Perl 5 as possible in one go
http://search.cpan.org/perldoc?perl5i
Other
156 stars 42 forks source link

Switch from Try::Tiny to TryCatch. #224

Open schwern opened 12 years ago

schwern commented 12 years ago

Try::Tiny has been useful, but it has a lot of caveats.

Now that we're using Devel::Declare, TryCatch is a possible replacement for Try::Tiny.

There are some issues:

It uses Moose

This adds unacceptable load time. It only uses this to parse the catch signatures (via Parse::Method::Signatures). It's possible a stripped down version of TryCatch could be written, with pluggable catch signatures, and TryCatch is built on top of that using Parse::Method::Signatures. Our own would use perl5i's internal signature handling.

Don't actually know if its any faster

This would require some benchmarking. Put your results on this issue as a comment.

The behavior of return is different from eval.

It turns out that return will return from the eval block, not the enclosing subroutine. This is surprising to me, I'd never thought it would do this, and quite patently wrong. So that TryCatch behaves differently is a bonus IMO but would be a big incompatibility.

Its incompatible with Try::Tiny

Thus this would have to be a perl5i::3 feature.