in reply to Re^13: eval to replace die?
in thread eval to replace die?
<chromatic> errors like "Error:ID:001|description|extradata:eins,zwei,drei" are terrible, because if you parse them with regexes, shit is hilariously easy to break in ways that are hell to debug or worse, you won't even NOTICEYou completely miss the crucial difference between a simple string comparison and a regex to deparse something. The former is fine because that's what perl even does when calling builtins, because they are ALSO in a hash table. The latter is a nightmare when you're dealing with inputs that are bound to change.
<BrowserUK> but with exception objects you still have to compare strings, SO THERE!
Um...apart from that it wasn't available until 5:30am todayMy example is a cut-down version of the synopsis, with some things changed to make it more readable for perl developers who are really adverse to thinking about things. Furthermore, the synopsis works. You can dump it into a .pl file, add a hashbang at the top and execute that and it will just plain work.
The module synopsies use: ... Which to the best of my abilities, simply doesn't work!
essentially throws away the purpose of half the code including two of the dependencies of E::C.E::C's code consists of two files:
There should *never* be an occasion when the failing routine has to pass you information to deal with an exception that you don't already have access to. After all, you called the routine and passed it the relevant information!You have never worked in a team where components are written by different people.
eval & die is a legitimate other way; that has been acceptable to Perl programmers for the best part of 20 years; and is used, where needed, by 18,000+ (-60 that use E::C) CPAN modules.Do you think Justin Bieber is an amazing artist and provides rich value to the human culture? (Hint: Appeal to popularity is a fallacy.)
But does no one see how easy and lightweight that can be done: die %hashYes, i did that for a while. It's nicer than strings, for reasons explained at the top, but it's also a bit clunky and makes you type a lot of stuff. I ended up having to boilerplate a lot when throwing exceptions like that, so having a module that provides a bunch of that kind of stuff in one is neat.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^15: eval to replace die?
by BrowserUk (Patriarch) on Oct 09, 2010 at 10:09 UTC | |
by mithaldu (Monk) on Oct 09, 2010 at 11:11 UTC | |
by BrowserUk (Patriarch) on Oct 09, 2010 at 14:14 UTC | |
by mithaldu (Monk) on Oct 09, 2010 at 16:02 UTC | |
by BrowserUk (Patriarch) on Oct 09, 2010 at 19:51 UTC | |
|