Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^5: $1 not "freezing" in an addition

by Anonymous Monk
on Dec 14, 2012 at 16:14 UTC ( #1008868=note: print w/ replies, xml ) Need Help??


in reply to Re^4: $1 not "freezing" in an addition
in thread $1 not "freezing" in an addition

The problem occurs in... This is very hard to detect through static analysis of source code; it's probably not especially easy to detect at run-time either.

Yes, I recognized that, but since PPI certainly detects  $1 and s/// as $1 and substitution operator, I see no reason perlcritic couldn't do the same, it uses PPI

I also recognize the abilities of warnings/lint, they actually run the code and can detect this case as well -- sure it might be too much to ask from warnings (could be slow) , but its not too much to ask of lint :)


Comment on Re^5: $1 not "freezing" in an addition
Download Code
Re^6: $1 not "freezing" in an addition
by chromatic (Archbishop) on Dec 14, 2012 at 18:10 UTC
    I see no reason perlcritic couldn't do the same

    PPI won't descend into functions or methods and can't descend into XS. You can only get so far with static analysis when trying to find all modifications of a global variable at or below your current call site.

      PPI won't descend into functions or methods

      Doesn't stop perlcritic from doing the descending, or running B::Xref

      and can't descend into XS

      descending into XS is not insurmountable either

      You can only get so far with static analysis when trying to find all modifications of a global variable at or below your current call site.

      You can well get pretty far I tell you what

      who says we have to find them all? or even descend? or even all globals?

      I see no use case for relying on the behaviour we see here , so IMHO it seems like a very safe low level warning for every  $global ... func to be turned into  "$global" ... func , esp for $1

        Doesn't stop perlcritic from doing the descending, or running B::Xref

        How is P::C to descend into code that's not loaded until runtime?

        descending into XS is not insurmountable either

        How is P::C to descend into compiled code that's not loaded until runtime and for which the source code is not available?

        IMHO it seems like a very safe low level warning for every $global ... func to be turned into "$global" ... func , esp for $1

        How do you know you've caught every global? How do you know stringification is desirable?

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (12)
As of 2014-07-25 14:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (172 votes), past polls