Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

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.


Comment on Re^12: eval to replace die?

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (18)
As of 2014-07-10 14:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (212 votes), past polls