Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

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

by adrianh (Chancellor)
on Jan 21, 2007 at 18:10 UTC ( #595786=note: print w/replies, xml ) Need Help??


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

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"?

Replies are listed 'Best First'.
Re^4: Use of "die" in OO modules
by theguvnor (Chaplain) on Jan 26, 2007 at 01:31 UTC
    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 :)

        Are you saying that if I eval { die MyExceptionClass->new(...) }; that the $@ variable will contain the instance of MyExceptionClass? Wow. It never dawned on me that that might be the case... This changes everything!

        [Jon]

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://595786]
help
Chatterbox?
[Discipulus]: :=(
[perldigious]: I watched some video on YT awhile back with auto-subtitle on and the speaker had a very thick cockney sort of English accent... hillarity ensued in the subtitles.
[Discipulus]: IHAA=I hate acronyms anyway
LanX LOLs
[perldigious]: If you want a linguistic adventure...
[perldigious]: No offense to any Scotsman, I love Scots. Well actually, I love Scotch, but I'm sure the people are great too. :-P
[Discipulus]: perldigious i understand i word on ten, to be optimistic..

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (9)
As of 2017-06-23 16:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How many monitors do you use while coding?















    Results (552 votes). Check out past polls.