I just got this message unexpectedly:

  Use of inherited AUTOLOAD for non-method main::consider() is deprecated at 
H_int2 line 50.
  Can't locate auto/main/consider.al in @INC (@INC contains: ...)

instead of the expected:

  Undefined subroutine &main::consider called at H_int2 line 50.

After a brief analysis determined that use of Inline::C elsewhere in the
program was responsible for diverting the message, a google found this
Dec 2001 message from Neil which doesn't seem to have received any answers
(<http://www.nntp.perl.org/group/perl.inline/923>);

:> I get this message when I run the program:
:> 
:> $ perl powerMonitor.pl
:> Use of inherited AUTOLOAD for non-method main::allow_access() is deprecated 
:> at powerMonitor.pl line 25.
:> Can't locate auto/main/allow_acces.al in @INC (@INC contains: 
:> /home/ned/.Inline/lib /usr/lib/perl5/5.6.1/i686-linux /usr/lib/perl5/5.6.1 
:> /usr/lib/perl5/site_perl/5.6.1/i686-linux /usr/lib/perl5/site_perl/5.6.1 
:> /usr/lib/perl5/site_perl/5.6.0 /usr/lib/perl5/site_perl/5.005 
:> /usr/lib/perl5/site_perl .) at powerMonitor.pl line 25
:
:This annoying message has plagued Inline from the start. Does anyone out
:there know how to explicitly disallow inherited AUTOLOADs? I'd much rather
:the script just crash.

I think the answer is not to mess with inheritance at all: the way this all
works is just like the way AutoLoader works, and I'd expect the solution
to be the same too. There is a downside though: AutoLoader installs its
AUTOLOAD into the calling package if asked to do so, else it requires that
you add a couple of (documented) lines into your own AUTOLOAD subroutine -
from AutoLoader's synopsis:
           package Foo;
           use AutoLoader 'AUTOLOAD';   # import the default AUTOLOAD subroutine

           package Bar;
           use AutoLoader;              # don't import AUTOLOAD, define our own
           sub AUTOLOAD {
               ...
               $AutoLoader::AUTOLOAD = "...";
               goto &AutoLoader::AUTOLOAD;
           }

In the case of Inline::C, I suspect the current behaviour would have to
remain the default for backwards compatibility, but I'd like to see the
option of requesting a choice of:
- export me an AUTOLOAD, leave my @ISA alone
- trust me to do the AUTOLOAD myself, and still leave my @ISA alone
as alternatives.

I think the only tricky bit would be documenting the 'trust me' option,
since I'm guessing you'd have to call the AUTOLOAD in the autogenerated
compiled package rather than in Inline::C itself, but I haven't looked
closely enough at the code to determine that for certain.

Yet another approach would be to avoid all this effort to defer loading,
forget both AUTOLOAD and @ISA, and export the compiled XS subs and
variables into the caller's namespace directly - if deferring the loading
is necessary, it isn't that hard for the caller to do it, either with
C< eval(q{use Inline 'C' ...}) > or with
<C< require Inline; Inline->import(C => ...) >>.

Hugo

Reply via email to