I suppose you probably hit this problem more often than many of the rest of us ;-) Then again, you may notice more than the rest of us...
What surprised me when I looked at the doc was that we actually had to type "eval" ourselves. I kind of expected it to take a coderef or string, and perform the eval itself. (This may have still required "sub" since prototyping wouldn't work for this, and since you're using objects where I don't think prototyping works anyway.)
A bit more thinking, and I'm wondering why all the overhead in the first place. If you had an exportable SafeEval (maybe two - one taking strings, the other taking a code ref via a prototype to look more like the built-in eval) which automatically created the object and returned that, it would definitely make this much simpler. And simpler means faster adoption. And that means more safe perl code out there. IMO, it may even make it harder to misuse the module (again, producing more safe code).
These eval functions would be able to set up all the handlers, do the eval, and take down all the handlers before returning back. That should also get rid of your overlapping issues - there'd be no hanging-on of previous handlers - the only way to overlap really would be having one eval inside another (directly or indirectly).use Devel::EvalError; my $ee = EvalExpectOne { ...; 1 }; ... $ee->Reuse(); $ee = EvalExpectOneStr "..."; # EvalExpectOneStr could append the "; 1 +" to the end automatically
Then, for absolute convenience, I'd suggest that EvalExpectOne probably could do everything via Contextual::Return:
But that's probably getting too convoluted ;-) ("Too much black magic")return BOOL { $obj->Succeeded() } STR { $obj->Reason() } LIST { $obj->AllReasons() };
In reply to Re: Devel::EvalError lives
by Tanktalus
in thread Devel::EvalError lives
by tye
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |