Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

(tye)Re: use Fatal;

by tye (Cardinal)
on Jan 10, 2002 at 05:06 UTC ( #137642=note: print w/ replies, xml ) Need Help??


in reply to use Fatal;

I've long felt that Fatal (or a module based on Fatal.pm) needed much greater coverage including print, printf, opendir, seek, write, truncate, kill, pipe, bind, connect, listen, send, socket, chown, chmod, utime, etc. without the user having to name any of these (and, personally, I think a failed close should never warrant more than a warning). And should default to only being fatal when in a void context.

Then we need a single module that rolls this,strict, and warnings (and only optionally diagnostics) together with a short, catchy name so that we can tell initiates to simply add -MAID or use AID; to all of their scripts to catch lots of simple mistakes.

        - tye (but my friends call me "Tye")


Comment on (tye)Re: use Fatal;
Download Code
Re: use Fatal;
by cLive ;-) (Parson) on Jan 10, 2002 at 05:12 UTC
    Got it!
    #!/usr/bin/perl use Bulletproof;
    ;-)

    cLive ;-)

(ichimunki) re x 3 : use Fatal;
by ichimunki (Priest) on Jan 10, 2002 at 05:22 UTC
    Well, why not throw in taint, a decent assert() function, and a call to your insurance agent to see if you're covered for that. ;)
Re: (tye)Re: use Fatal;
by Anonymous Monk on Jan 10, 2002 at 05:31 UTC

    Another problem with the current version is that it only overrides the given functions in the current package, so all modules and embedded packages must also use it to get the functionality you might want.

    #!/usr/bin/perl -w use strict; use Fatal qw/open close/; package Foo; #use Fatal qw/open close/; sub bar { open(FILE,'dfdsadf'); close FILE; } package main; Foo::bar();

    It should at least be a lexically scoped pragma so the above would be fatal without reissuing the use statement. I'm not sure how it could be made to globally overide such functions in all used packages.

      That is what *CORE::GLOBAL::open= coderef is for. And if it only makes things fatal when in a void context, then this shouldn't be much of a problem for module code that doesn't know whether the user might use this or not.

      You can write code that would break in such cases but I don't consider such code to be reasonable so I don't mind. (:

      open( FILE, "< this.txt" ); warn "Can't read this.txt: $!\n" unless defined fileno FILE;

              - tye (but my friends call me "Tye")
Re: (tye)Re: use Fatal;
by demerphq (Chancellor) on Jan 14, 2002 at 18:15 UTC
    Then we need a single module that rolls this,strict, and warnings (and only optionally diagnostics) together with a short, catchy name so that we can tell initiates to simply add -MAID or use AID; to all of their scripts to catch lots of simple mistakes.

    I suggested exactly this (and coded up a prototype) quite a while back, the name I came up with was

    use caution; #or no caution;
    But if you have a look at the responses I recieved on CLPM to my post(I didnt know about Perlmonks at the time) it was to say the least not a popular suggestion. However if you think it is a good idea I can have another look at it, and include 'fatal' with the defaults you suggest and post it here for review. (BTW I even reserved the namespace ex::caution on CPAN, but havent uploaded it yet. sigh.)

    Yves / DeMerphq
    --
    When to use Prototypes?

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (8)
As of 2014-09-02 08:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (20 votes), past polls