Beefy Boxes and Bandwidth Generously Provided by pair Networks BBQ
There's more than one way to do things
 
PerlMonks  

Re^2: Use of "die" in OO modules

by theguvnor (Chaplain)
on Jan 19, 2007 at 08:36 UTC ( [id://595450]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to Re: Use of "die" in OO modules
in thread Use of "die" in OO modules

Thanks for the link - interesting reading. The whole raison d'etre for my original post was that though I philosophically fall into the same camp, I have problems with the implementation/execution - in the absence of true built-in Exception handling, I have to decide between a couple of options: either fake up a try/catch type of thing by using eval {...}; if($@){...} or go with the old return undefined and let the caller inspect the object's error() method.

[Jon]

Replies are listed 'Best First'.
Re^3: Use of "die" in OO modules
by adrianh (Chancellor) on Jan 21, 2007 at 13:10 UTC
    in the absence of true built-in Exception handling

    I'm curious, since I've heard others saying this, why you think Perl's exception handling isn't "true" or "built-in"?

      Well, I guess it's a matter of defining what we mean. My definition would be that when code does something exceptional i.e. contrary to the "normal" flow or producing an unwanted error condition, the interpreter will interrupt program flow by propagating an object that encapsulates the error information, up through the stack until it finds code ready to handle it. The key here is that while die within an eval{} sets $@, that is an error variable, but it is not really much of an object (at least, not in the sense that it's commonly used and understood by practitioners of Object-Oriented paradigm). I'm aware that there are CPAN modules that implement Exception classes, but the fact is they're not integrated into the language at the deepest levels. (Whether that's a good thing or bad is, well, opinion I guess.)

      [Jon]

        but it is not really much of an object (at least, not in the sense that it's commonly used and understood by practitioners of Object-Oriented paradigm

        Well - you get as much of an object as you give it. If you die with a string you get a string. If you die with an object you get an object. We don't have a specialised exception class - but that's the way Perl 5 is in general :)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://595450]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.