Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: static method checker for perl?

by DStaal (Chaplain)
on Apr 07, 2009 at 20:01 UTC ( [id://756133]=note: print w/replies, xml ) Need Help??


in reply to static method checker for perl?

In general no. Perl is a little bit too dynamic for that: many modules create methods at runtime (usually using AUTOLOAD, but there are other ways...), and all methods and functions in Perl take exactly one argument: A list, which will be put in the @_ array. (Even prototyped functions take a list. They just define what's in the list.)

So the problem is that none of the above is known until runtime, when a specific method call is made. It may be possible to answer those questions for a fair number of simple cases, but default arguments and AUTOLOADed methods are both fairly common practice.

Replies are listed 'Best First'.
Re^2: static method checker for perl?
by chromatic (Archbishop) on Apr 07, 2009 at 23:46 UTC
    Even prototyped functions take a list. They just define what's in the list.

    While that may be technically true (Perl uses a stack), I'm not sure that's helpful. Prototyped functions parse differently from regular Perl functions, so the apparent behavior of these functions may not make it apparent that they take lists of arguments.

      Agreed. I just wanted to indicate I was aware of prototypes. (I didn't feel a more in-depth discussion on them was needed to answer the question given.)

      But yeah, prototypes cause the function to apply different contexts to their arguments (except when they don't) and so they can appear to take something other than a list. Unless you ignore the prototype. Or work around it some way. Or...

      End result, for this discussion: Prototypes in Perl don't actually help all that much with static code analysis. They can help a bit, but not enough to make code analysis really useful.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2024-04-19 22:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found