Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: RFC: Lexical Fatal.pm for Perl 5.10

by hossman (Prior)
on Mar 09, 2008 at 07:58 UTC ( #673068=note: print w/ replies, xml ) Need Help??


in reply to RFC: Lexical Fatal.pm for Perl 5.10

What should the module be called?
...
Should this module even exist? Am I duplicating existing work? Note that I'm using Fatal to do all the heavy lifting internally. To the best of my knowledge there's no existing way to use Fatal with lexical scope.

why not just make this a patch for Fatal triggered by an option on the use line (the option would be implicit for "no" since it's not currently supported and would imply lexicality anyway)?

use Fatal qw(:lexical open close); open(my $fh, '<', 'some_file'); # Throws exception on failure { no Fatal qw(open); open(my $other_fh, '<', 'some_other_file'); # fails silent close($fh); # This still throws an exception. no Fatal; # Turns off exceptions entirely. close($other_fh); # Fails silent. } close($yet_another_fh); # Throws exception on failure again.


Comment on Re: RFC: Lexical Fatal.pm for Perl 5.10
Select or Download Code
Re^2: RFC: Lexical Fatal.pm for Perl 5.10
by pjf (Curate) on Mar 09, 2008 at 08:26 UTC
    why not just make this a patch for Fatal triggered by an option on the use line

    This is an excellent idea, and one I really should have considered and mentioned in my original post. I'm very happy with the idea of a patch to Fatal; it keeps everything together, and it certainly simplifies the code.

    Downsides of patching Fatal are:

    • We'd be changing the behaviour of a core module, which means waiting until 5.10.1 before it's deployed, or making Fatal dual-lifed (core + CPAN).
    • I'd need to get sign-off from p5p, Lionel, or both. That shouldn't be a problem for a good idea, but it does have additional administrative overhead.
    • We're altering the interface of a very well-known core module to do something that it's never done before. There may be surprises there.
    • The calling syntax doesn't look like a pragma, but the more I look at it the less I mind. Using :lexical I hope makes it pretty obvious what's going on.

    The advantages are that it goes in the core for everyone to enjoy, my ability to reuse code in Fatal becomes much much easier, and the functionality goes in the place where I imagine most people will expect it to be.

    I'll open discussions with p5p to see their thoughts. Of course, I still very much appreciate feedback on the original proposal as well.

    Many thanks,

      I'm very happy with the idea of a patch to Fatal;

      That would be great, but failing that I think it'd be best to have a name which immediately suggests “like Fatal but works lexically”, such as Fatal::Lexical.

      Otherwise if we have, say, both Fatal and Lethal, there's nothing indicating which name has which behaviour; it seems arbitrary to anybody who doesn't already know.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (7)
As of 2014-08-23 15:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (174 votes), past polls