in reply to syntax error checking on object methods

I don't think anything like this exists, but it certainly sounds useful to me. It also sounds really, really hard to write! Consider this code:

my $obj = some_func($some_arg); $obj->method();

It won't be easy to figure out what class to inspect for method(). The class of $obj may depend on $some_arg, which itself might come from some obscure source. Since Perl is a late-binding language intuiting the class for any given variable in the general case is going to be very hard.

-sam

Replies are listed 'Best First'.
Re^2: syntax error checking on object methods
by Fletch (Bishop) on Nov 01, 2004 at 04:26 UTC

    Not to mention cases where the method name itself is dynamically computed at runtime.

    my $method = $phase_of_moon eq 'waxing' ? "discombobulate" : "vreemflitzel"; $obj->$method( $price_of_tea_in_china );
      I'd have missed both cases yes, so it's good I asked and I appreciate your answers. Maybe a full syntax checker on this is too much to desire, but a simple one that takes into account common cases where objects and methods are easily recognizable might not be that hard. In the long run a full syntax checker (if even possible) sounds like a good thing to have to me.