On Thu, Nov 06, 2003 at 07:32:45PM +0000, Graham Barr wrote: > On Nov 6, 2003, at 2:00, Michael G Schwern wrote: > > >On Wed, Nov 05, 2003 at 09:05:52PM +0000, Graham Barr wrote: > >>On Nov 4, 2003, at 23:13, Michael G Schwern wrote: > >>>So, basically, you pick up an AUTOLOAD by inheriting from any module > >>>that > >>>uses XS. Feeling paranoid yet? :) Should we change can() to ignore > >>>methods inherited from DynaLoader now? > >> > >>Thats been a known issue for a long time. The only reason you need to > >>inherit from DynaLoader is that bootstrap may call the dl_load_flags > >>method. > > > >Are you sure you mean dl_load_flags? It appears that the autoloaded > >methods are: > > What has autoloaded subs got todo with inheritance ? Sorry, I misparsed the above as "the only reason DynaLoader needs to inherit from AutoLoader". AutoLoader on the brane. > >>The annoying thing is that because you do have AUTOLOAD there then you > >>get different warnings. > > > >I've been pondering changing the AutoLoader error message so it looks > >a bit more like a normal method/function lookup failure. Possibly > >placing the normal error in front of the extended AutoLoader > >information. > >This way at least checks like > >$@ =~ /^Can't locate object method "$meth" via package "$class"/ will > >still work. > > But AutoLoader::AUTOLOAD has no way to be sure if what is being > attempted to be loaded was called as a method or a sub Yeah, there's the rub. I wonder if it could take an educated guess somehow. Check if the first argument is an object. Of course, then class methods won't work. *ponder*. Pragmaticly, I've rarely seen anyone check for. $@ =~ /^Undefined subroutine &${pack}::$func called/ Having AutoLoader spit out the normal method lookup failure message, regardless of whether it was a function or method call, is at least less wrong than its current behavior. Doesn't really make me happy though. Or we could do a fix for DynaLoader::AUTOLOAD similar to UNIVERSAL::import. Limit its scope. Since the autoloaded things in DynaLoader are functions... sub AUTOLOAD { my($class, $meth) = $DynaLoader::AUTOLOAD =~ /^(.*)::([^:]+)$/; croak qq{Can't locate object method "$meth" via package "$class"} unless $class eq 'DynaLoader'; $AutoLoader::AUTOLOAD = $DynaLoader::AUTOLOAD; goto &AutoLoader::AUTOLOAD; } This still leaves us with the wrong message should someone say: package Foo; require DynaLoader; @ISA = qw(DynaLoader); Foo::bar(); but its less wrong than "Can't locate auto/Foo/bar.al". With "Use of inherited AUTOLOAD for non-method Foo::bar() is deprecated" warning that goes along with it I think its less confusing. -- Michael G Schwern schwern@pobox.com http://www.pobox.com/~schwern/ 11. Every old idea will be proposed again with a different name and a different presentation, regardless of whether it works. -- RFC 1925Thread Previous | Thread Next