Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

Re^2: RFC: Lexical for Perl 5.10

by pjf (Curate)
on Mar 09, 2008 at 08:47 UTC ( #673075=note: print w/replies, xml ) Need Help??

in reply to Re: RFC: Lexical for Perl 5.10
in thread RFC: Lexical for Perl 5.10

maybe use lethal; makes more sense.

I love the suggestion. Thank-you! Project named internally to 'lethal'. ;)

It would be nice if the lexical module took care of installing and backing out the exception handler.

While I appreciate the desire here, I'd argue that lethal is the wrong place to do it. I expect most Perl developers are used to seeing exception handling occur at the bottom of code. In traditional Perl 5:

eval { scrub($decks); weigh($anchor); sail_to($destination); }; if ($@) { warn "Uh oh, we had a problem with $@"; }

Or when using the Error module:

use Error; try { scrub($decks); weigh($anchor); sail_to($destination); } catch Error::Anchor with { my $E = shift; warn "The anchor's stuck due to $E"; } otherwise { my $E = shift; warn "We're not sailing due to $E"; };

In both cases (and in most languages), the exceptions are handled at the end, or in the calling code. I'd certainly be surprised to see the exception handler before the code that may throw the exception.

However I will be mindful to ensure that lethal inherits cleanly, so this can be implemented easily in a child module if you think it's a good idea. ;)

Many thanks for the excellent ideas,

Replies are listed 'Best First'.
Re^3: RFC: Lexical for Perl 5.10
by BrowserUk (Pope) on Mar 09, 2008 at 09:40 UTC
    In both cases (and in most languages), the exceptions are handled at the end, or in the calling code.

    Well, if you use the $SIG{__DIE__} = sub (...) approach, this has to be done up front. The two approachs, signal handler and block eval serve slightly different purposes, but can be mixed I think.

    Anyway, good luck with your module :)

    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?

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (2)
As of 2018-03-24 09:10 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (297 votes). Check out past polls.