[Israel.pm] Detecting calls for unknown methods in compile time

Gaal Yahas gaal at forum2.org
Thu Sep 23 08:03:10 PDT 2010


There's no way to do this. Perl is a dynamic language, and functions
are added to packages at runtime all the time. Consider that
subclassing happens on-the-fly with @ISA (rarely put inside a BEGIN
block), and that AUTOLOAD means a package (or a class's ancestor)
might decide to handle -- or decline -- some call, pretty much
arbitrarily.

On Thu, Sep 23, 2010 at 1:46 PM, Ronen Angluster <beerholder at gmail.com> wrote:
> Hello all,
> please consider the following code:
> ###################################
> package main;
> my $x= main::foo->new();
> $x->bar();
> $x->barx();
> package foo;
> sub new {
> my $this = shift;
> my $class = ref($this) || $this;
> my $self={};
> bless ($self, $class);
> return $self;
> }
> sub bar
> {
> my $self = shift;
> print "foo\n";
> }
> #################################
> now, executing this code with "perl -cw script.pl" will not produce any
> errors since the call for the reference of "barx" will only
> be evaluated during runtime.
> is there a way to detect such errors in compile time?
> Hag Sameach,
> Ronen
> _______________________________________________
> Perl mailing list
> Perl at perl.org.il
> http://mail.perl.org.il/mailman/listinfo/perl
>



-- 
Gaal Yahas <gaal at forum2.org>
http://gaal.livejournal.com/


More information about the Perl mailing list