Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Re^12: eval to replace die?

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

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

Ah, but at least it's possible.

Certainly. It's also possible for me to write a large Haskell program in one go which passes the type checker the first time, but I don't rely on that.

It's impossible to do plain string compare that isn't fragile in the face of simple changes.

Absolutely. Yet consider how classes and objects give you abstraction possibilities beyond which you can hide internal changes. That is, if you need to change your exception hierarchy in an incompatible way, you have the possibility of maintaining a compatibility layer between the old version (which can give a deprecation warning) and the new version.

Bare strings don't give you that possibility.

If you use—as I do—an exception system which uses roles to encode specific details about the type of exception then the only exact string comparison is to the name of the role and not any wording of the exception message. At some level in the system, something does have to compare a string to the name of a role yes, but that doesn't rely on any user having to craft the right regular expression which blends future proofing with accuracy.

Whenever I write an exception system, I throw constants....

Sure, I've seen that work well. Code which will only compile when it's correct is an advantage in these cases.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://863443]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2017-10-23 23:51 GMT
Find Nodes?
    Voting Booth?
    My fridge is mostly full of:

    Results (285 votes). Check out past polls.