[Israel.pm] undefined subroutines not detected at compile time

Yossi.Itzkovich at ecitele.com Yossi.Itzkovich at ecitele.com
Wed Mar 16 23:07:07 PST 2005






Hi,

Dynamic - but partly compiled. Why the compiler can not detect simple cases
(not eval/AUTOLOAD etc.)

Yossi



                                                                                                                                    
                      Mikhael Goikhman                                                                                              
                      <migo at homemail.c         To:      Perl in Israel <perl at perl.org.il>                                           
                      om>                      cc:                                                                                  
                      Sent by:                 Subject: Re: [Israel.pm] undefined subroutines not detected at compile time          
                      perl-bounces at per                                                                                              
                      l.org.il                                                                                                      
                                                                                                                                    
                                                                                                                                    
                      03/17/2005 00:35                                                                                              
                      Please respond                                                                                                
                      to Perl in                                                                                                    
                      Israel                                                                                                        
                                                                                                                                    
                                                                                                                                    



On 15 Mar 2005 15:30:52 +0200, Yossi.Itzkovich at ecitele.com wrote:
>
> When I use both   -w and use strict, I expect Perl to find undefined
> subroutines at compile time (assuming I don't use references to
> subroutines).
> But it doesn't.
>
> It finds it only at run time - like a simple shell script.
>
> Is there to get such checks at compile time ?

Perl is a dynamical language, fortunately or not.

This can't be checked at compile time. Here are 3 examples that
demonstrate why (all are perfectly valid perl idioms that are used
in real life, yet you suggest that they should issue a warning).

% perl -w -Mstrict
eval 'sub undefined_function { print "Hello, World\n"; }';
undefined_function();

% perl -w -Mstrict
sub AUTOLOAD { print "Hello, World\n"; }
undefined_function();

% perl -w -Mstrict
undefined_function() if main->can("undefined_function");

Regards,
Mikhael.

--
perl -e 'print+chr(64+hex)for+split//,d9b815c07f9b8d1e'
_______________________________________________
Perl mailing list
Perl at perl.org.il
http://perl.org.il/mailman/listinfo/perl






More information about the Perl mailing list