Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re^4: eval to replace die?

by chromatic (Archbishop)
on Oct 04, 2010 at 14:51 UTC ( #863351=note: print w/ replies, xml ) Need Help??


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

And what does isa() do that isn't subject to exactly the same error vectors a string compare?

It doesn't perform a regular expression match, for one. If you've never changed the text of an exception message and then had to change the regex of handlers, good. I have.

The problem with Java isn't structured exceptions. It's one part "Wow, look at how awesome we can make a fragile hierarchy!" and two parts mandatory structured exceptions.


Comment on Re^4: eval to replace die?
Re^5: eval to replace die?
by BrowserUk (Pope) on Oct 04, 2010 at 15:44 UTC
    It doesn't perform a regular expression match, for one.

    So now you are demonising regular expressions? Should we scrap regexes all together?

    If you've never changed the text of an exception message and then had to change the regex of handlers, good. I have.

    And you've never had to restructure your exceptions? I have.

    I say again, how is that different?

    Look at all the places in the Exception Class example I posted where the (same) name of the exception (class) is embedded inside a string.

    • Think about how many opportunities that creates for typos.

      Typos that are not even subjected to the rigours of syntax checking.

      By moving your error texts into the name-space hierarchy, you've just moved the problem elsewhere and wrapped it up in a heap of complexity.

      You've re-created the very problems that Abigail attempted to address with Inside Out objects. That of preventing strict from working by putting program "keywords" into hash keys. Stashes are just hashes.

      And along the way, thrown away a bunch of useful tools. Like regex.

      Which means you can no longer follow Postel's Prescription: "Be generous in what you accept, rigorous in what you emit", because (for example) you cannot use a regex with /i to ignore casing.

      Or just $@ =~ /^Uninitialised variable/ to match just the invariant part of the error.

    • And all the places in that example that need to be changed when you inevitably have to re-structure your exception handling.

      You've just quadrupled the number of places in the code you need to change. And in the process added 3 more layers; 5 more dependencies; and a crap load more code into the bargain.

      There is an undeniable truth that says: more code == more bugs. And you've just added a bunch more complicated code trying to avoid a situation that can be trivially dealt with without it.

    Maybe those can be avoided by using Exception::Class better? If so, please enlighten us with an example.


    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.
      Should we scrap regexes all together?

      How do you go from "Converting structured information to strings, then using regular expressions to attempt to extract structured information is fragile" to "Don't use regular expressions"?

      Or just $@ =~ /^Uninitialised variable/ to match just the invariant part of the error.

      Invariants often aren't. See also theory's comment about localizing Bricolage.

      And you've never had to restructure your exceptions?

      Of course I have. Code changes. Changing regular expressions used for control flow because data has changed is different.

        No. I reach there by extrapolation from your "It doesn't perform a regular expression match, for one."

        You say that, thereby implying that regular expressions are a bad thing.

        I just take your words to their logical conclusion. It's called proof by contradiction; or disproof by "Reductio ad absurdum".

        If regular expressions are so bad for exception handling; why would they be reliable for anything else?


        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.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (16)
As of 2014-07-29 09:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (212 votes), past polls