in reply to Compile-time/Auto-test method checking?

The only¹ static approach I can think of is to restrict/enrich an object model in a way to define the methods statically.

That means you can extend each class you use with information (eg an array or flagging them with attributes) about the method names.

Then you can get the information which classes use which methods without running the class-code.

Well you can easily do this with your own code... and I suppose you don't plan changing method names of foreign classes...

BUT then you still have the problem to identify statically which class an object belongs to. An object in Perl is just a blessed reference to a data structure. A reference might have been created from somewhere without any "new class" syntax in the same file to parse.

So you have to enrich your code with type-declarations (should be possible with attributes)

So it's possible (you will be mimicking the mechanisms of static languages) but is this still perl???

There are plenty of discussions of this in Perlmonks (search for static parsing and ppi), you might want to check if IDE-extensions like perlysense for emacs or padre already provide any automated help.

Cheers Rolf

UPDATE: (1) reliable

  • Comment on Re: Compile-time/Auto-test method checking?

Replies are listed 'Best First'.
Re^2: Compile-time/Auto-test method checking?
by Anonymous Monk on Jun 26, 2009 at 13:34 UTC
      > Module::Inspector, Class::Inspector

      well yes, AFAIK these are ppi spin-offs and Gabor's approach for padre.

      But if the OP is only talking about self-written classes and compares to java he might be happy about a robust attribute¹ based solution instead of relying on ppi's "guessing what the author meant".

      BTW: How do these modules handle AUTOLOAD?

      Cheers Rolf

      UPDATE: (1) Attribute::Handlers