Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: When -w and use strict aren't enough...

by adrianh (Chancellor)
on Nov 04, 2003 at 13:55 UTC ( [id://304415]=note: print w/replies, xml ) Need Help??


in reply to When -w and use strict aren't enough...

But it would be nice if there was a way to catch such cases...

Well, you've answered your own question when you said:

"there could be autoloads providing the subroutine, or it could have been dynamically generated at runtime in an eval, or something. "

The flexibility of Perl comes with a price. This is one of them.

However, I would strongly disagree when you said:

without having to write a test suite that exercises every code branch, which isn't always (or even usually) possible.

If you can't test your code then something is wrong with it. Fix the design so you can test it. If you have problems doing this, then post a SOPW - I'm sure somebody could help ;-)

Seriously, 100% test coverage is an attainable goal with surprisingly little effort.

  • Comment on Re: When -w and use strict aren't enough...

Replies are listed 'Best First'.
Re: Re: When -w and use strict aren't enough...
by ysth (Canon) on Nov 04, 2003 at 15:04 UTC
    You can say that it has been the price, but I see a good niche for adding the ability to turn on stronger checking in this area.

    Even with subs dynamically generated at runtime or handled via AUTOLOAD, offhand I can think of no case where there couldn't be at least a declaration at hand at compile time. It is Unfortunate that sub declarations aren't common enough in CPAN modules to allow this to be a default check.

      Of course it is technically possible to see if an appropriate entry exists in the symbol table at runtime. However, forcing everybody to add declarations for any runtime-generated subroutines strikes me as both un-perlish and extremely unlikely to happen.

        However, forcing everybody to add declarations for any runtime-generated subroutines strikes me as both un-perlish and extremely unlikely to happen.

        There's no reason it couldn't be a pragma. Why stop with use strict; use warnings; use diagnostics;  use Taint; when you can add use predeclaredsubs; use predefinedsubs; and maybe no earlyreturns; no typeglobs; and possibly use bondage; use discipline; use pain; use Inline::Pascal;


        $;=sub{$/};@;=map{my($a,$b)=($_,$;);$;=sub{$a.$b->()}} split//,".rekcah lreP rehtona tsuJ";$\=$ ;->();print$/

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (4)
As of 2024-04-25 16:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found