Your skill will accomplish what the force of many cannot |
|
PerlMonks |
Re^3: Can someone please write a *working* JSON moduleby Anonymous Monk |
on Oct 26, 2021 at 08:48 UTC ( [id://11138052]=note: print w/replies, xml ) | Need Help?? |
It doesn't have to be a dichotomy. Exceptions can be used when you need to fail the operation and jump in an overall exception handler multiple functions above in the call stack. Success/error return values (preferably when they are of different types and the compiler can make sure you're not using the success type in the error branch, a.k.a. the Optional<Success, Failure> idiom) can be used when you can check for and handle the error right away. People who use exceptions won't argue in favour of code like the following: That's just more typing for the same result as
On the other hand, if an error means the whole operation should be aborted and the individual steps signal that by raising an exception, we can write it as and still be sure that when the error happens, (1) any resources will be cleaned up safely by desctructors and (2) the following steps won't be taken. By the way, why do you dislike eval? I mean, I don't like eval EXPR either, but what's wrong with eval BLOCK?
In Section
Seekers of Perl Wisdom
|
|