Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re^15: eval to replace die?

by BrowserUk (Pope)
on Oct 09, 2010 at 10:09 UTC ( #864356=note: print w/ replies, xml ) Need Help??


in reply to Re^14: eval to replace die?
in thread eval to replace die?

Alright, i'll give it one more try to see if i can get through to you.

There is no need for you to "try to get through" to me. I understand what you (and others) are saying. I just disagree with your conclusions, and I've tried (hard) to present my reasoning in detail. You can either accept or reject my reasoning, but re-stating your flawed position over again will not change my reasoning, nor my conclusions.

You completely miss the crucial difference between a simple string comparison and a regex to deparse something.

No I didn't. But you apparently didn't read half my post, because it you had you have read the bit where I showed that there is no good reason to "deparse" the error string.

"Exhibit one" fully rebutted!

Have you even tried that

Of course I did, but the synopsis code, all in a single file, is not useful. So I tried and posted a realistic example. It doesn't work:

C:\test>exceptions 1 0 Can't locate object method "throw" via package "MyExceptions" at C:\te +st\exceptions.pl line 8.

I invited corrections, none were forthcoming.

My example is a cut-down version of the synopsis, with some things changed

And the things you changed mean that you're not using half of the functionality of the module. You don't use either of the ->throw() or the ->caught() methods. You use Try::Tiny for this functionality, presumably because you couldn't get them to work either.

BTW: E::C throw() and caught(), and Try::Tiny's use of die and catch{} are overlap!.

(Hint: Appeal to popularity is a fallacy.)

Statements of verifiable fact are not "appeals to popularity"; and by definition, cannot be "fallacy".

Do you think Justin Bieber ...

Who?


Further restatements of our respective positions serve no purpose. Let's just accept that you think I'm an idiot; and I think that you are too caught up in trying to suggest that I am, to have bothered to read what I've written and make any real attempt to apply logic to it.

I'm done.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.


Comment on Re^15: eval to replace die?
Select or Download Code
Re^16: eval to replace die?
by mithaldu (Monk) on Oct 09, 2010 at 11:11 UTC
    re-stating your flawed position over again
    "=~ is more volatile than eq/ne" is flawed?


    I invited corrections, none were forthcoming.
    Yeah, sorry, i admit i didn't bother to read every single thing before my first post because stuff is very wordy. Here's your problem:

    use Exception::Class <stuff_here>; does two things: First, it instantiates all the classes you ask for. In this case MyException being one of them. Optionally you can also ask it to export shortcut subs into the module where you use it. In your case you only ask it to export throw_fields.

    To fix your example, change the two "MyExceptions" in sub divide to "MyException", so you're actually trying to throw with the class of an exception (by your use of caught, this is presumably the right option).
    D:\Exception-Class-OnCaller>perl bluh.pl 1 0 The second argument must not be zero at bluh.pl line 38.

    And the things you changed mean that you're not using half of the functionality of the module. ... E::C throw() and caught()
    These are merely convenience functions, clocking in at 15 of 415 code lines (without docs). That is 3.6%. The rest and the majority of the code deals exclusively with the creation of exception objects.

    The only reason i did not use them is because i personally do not like them and think T::T looks nicer. Your assumption that i could not get them to work is not correct as my fix to your example above proves.

    "Ex->throw" is literally just a shortcut for "die $ex || Ex->new". This has nothing to do with T::T's try, since THAT function does much more stable wrapping of code and does nothing to create exception objects, but only stores them if the wrapped code emits them.

    "caught" is only there so you can inspect the errors from the eval and compare them to certain targets in one line. It has only superficial resemblance to try's catch, which is aimed at security and stability and does not have the convenience of actually inspecting the exceptions.

    The intent of Exception::Class is merely to provide exception objects, not to provide exception handling. These are two very different domains.

    Let's just accept that you think I'm an idiot
    I don't. At this moment i am of the belief that your hate of another language(*) does not allow you to evaluate things in a complete and rational manner. If i had good memory i would insert a jedi quote here.

    (*) And on inspection of your the post with your example, also your hate of one specific person.
      "=~ is more volatile than eq/ne" is flawed?

      Yes. It takes only a one character typo or transposition to screw either up. And once tested, both are proven until something changes. When something changes, both need to be re-tested. Regex may be harder to get right, but once they are tested as correct, they don't suddenly start randomly acting differently. If they matched today, they will match tomorrow, unless something else changes. And when something else changes, it is just as likely to screw up eq as =~.

      That is a complete, dispassionate, rational evaluation. It is also incontrovertible.

      i am of the belief that your hate of another language...

      The language in question I think has done the industry I've loved being a part of for the last 30 years, a considerable disservice.

      Java probably has no more bad programmers as a percentage, than any other language, but because they are a) more numerous than most other languages; and b) the consequent high demand for them, means that forces of natural selection that usually weed out the worst, hasn't operated as it normally would; combined with c) the artificial "legitimacy" that somehow arose around it; means that companies around the world have tried to reduce the art of programming--and programmers--to a commodity items.

      Instead of employing a number of higher paid, higher skilled programmers and analysts (and project managers), they started trying to throw large numbers of low-paid, less skilled people at projects. Java enables that because it effectively reduces all language development to a single construct: object.action( args );. This is very easy to teach, and so you can push large numbers of people through certification processes very quickly. But along the way it produced a whole generation of programmers that know only one way to everything. They have no exposure to procedural, funtional or any other style of programming than OO. And that's a monoculture. And monocultures are always bad.

      The result is that each individual developer, analyst or architect concentrates upon one tiny part of an overall project with no one person having a full overview. And the bloated, discordant, memory and cpu hungry results of that have become manifest.

      I like OO. I use OO (when appropriate). I'm even quite good at OO. So your attempts to label me an "OO hater" cut no ice. I'm just sufficiently experienced to know that there are other ways of doing things; and for many problems they are better.

      also your hate of one specific person.

      It is a matter of personal ethics that I don't "hate" anyone. Much less people I have never met, nor even had a one-on-one conversation with.

      Read my sig. I argue the the issues; never the person. But you cannot argue the issues effectively without talking to their main proponents. Trying to take my arguments against a person's stated position; as any kind of emotional attack on that person, is the last refuge of the desperate.

      I love the Perl language. And I take issue with anyone I perceive to be advocating the "dumbing down" and commoditasation of Perl. I do so, because I believe that it is detrimental to Perl in the wider context. But I have nothing to gain from my efforts except, perhaps, whatever long term effects my dispassionately logical arguments might have upon individual members of the Perl community. Or not.


      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.
        Just a simple real life example, derived from my day to day work:

        An application that deals with item prices delivered by third party servers (so, unknown ahead of time) and does a change check before each action that has to do with actual cash. If the price changes, it backs out and tells the user, with the message highlighted in red or green. Prices are displayed in full euro values at all times for brevity.

        With exceptions:
        die { type => 'PriceChange', amount => -123 };
        The exception handler can recognize it by eq'ing the type and derive the direction from doing a numerical inspection of the amount and then shunt the whole thing through a template generator.

        With strings:
        die "PriceChange: The price changed by -123 Euro.";
        The exception handler does:
        $error =~ m/^(\w+)\:.* ([-\d]+) /; if ( $1 eq 'PriceChange' ) { my $direction = determine_direction( $2 ); return price_change_error( $error, $direction ); } else { return "UNKNOWN ERROR!"; }

        Both work fine. Now management decides: "We want the decimals displayed!"

        So the die errors get changed:

        die { type => 'PriceChange', amount => -123.45 };
        die "PriceChange: The price changed by -123.45 Euro.";


        You see what happens, right? And just in case you try to argue "this code is dumb", yes it is. But let me assure you it's tame against the shit i've seen in production over the years.


        And lastly, i'm not going to try and address your wall of text at the bottom there. I dislike Java as well, i dislike OO as well and only use it when i can't think of a lispy way to do something. But i never labeled you as an OO-hater, you made that up on your own. I merely said that i think you're too busy hating Java to allow yourself to see that E::C has little to do with it at the core.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://864356]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (7)
As of 2014-09-03 03:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (35 votes), past polls