Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

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]
[Discipulus]: he does not learn, nor teach, nor learn
[planetscape]: hello all
[stonecolddevin]: o/ planetscape
[Sinistral]: I think that just the sight of his username now causes a downvote storm. I agree, and the gratuitous use of formatting does make reading hard. I've given him +1 on things where there seemed to be actual good advice, but I think the big
[Sinistral]: nail in coffin was the rant against a Schwarzian Transform
[stonecolddevin]: at best, from what i've seen, his knowledge is accurate up to maybe 2002. the sheer volume of words is mostly worthy of a downvote in most cases though i think
[erix]: ITYM Schwartzian Transform :P
[erix]: hey planetscape :)
[planetscape]: howdy stonecolddevin, erix
[Sinistral]: eric Aye. I thought I typed that wrong. All hail Randall! I listen to him on FLOSS Weekly

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (10)
As of 2017-06-22 20:54 GMT
Find Nodes?
    Voting Booth?
    How many monitors do you use while coding?

    Results (530 votes). Check out past polls.