Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re^9: Use of inherited AUTOLOAD for non-method is no longer allowed with Perl 5.34. (SSCCE)

by LanX (Saint)
on Sep 29, 2021 at 10:40 UTC ( [id://11137107]=note: print w/replies, xml ) Need Help??


in reply to Re^8: Use of inherited AUTOLOAD for non-method is no longer allowed with Perl 5.34.
in thread Use of inherited AUTOLOAD for non-method is no longer allowed with Perl 5.34.

> (untested, till someone provides a real SSCCE)

here we go to prove my theory

this works (in a wider sense ;):

use strict; use warnings; # https://perlmonks.org/?node_id=11137026 package Base; use Data::Dumper; sub AUTOLOAD { our $AUTOLOAD; warn "$AUTOLOAD => ", Dumper \@_; } #*UNIVERSAL::AUTOLOAD = \&AUTOLOAD; package Bla; *AUTOLOAD = \&Base::AUTOLOAD; # aka Bla::AUTOLOAD some_sub(1,2,3); *Foo::AUTOLOAD = \&Base::AUTOLOAD; Foo::some_sub(4,5,6)

-*- mode: compilation; default-directory: "d:/tmp/pm/" -*- Compilation started at Wed Sep 29 12:33:29 C:/Strawberry/perl/bin\perl.exe -w d:/tmp/pm/universal_autoload.pl Name "Foo::AUTOLOAD" used only once: possible typo at d:/tmp/pm/univer +sal_autoload.pl line 25. Name "Bla::AUTOLOAD" used only once: possible typo at d:/tmp/pm/univer +sal_autoload.pl line 19. Bla::some_sub => $VAR1 = [ 1, 2, 3 ]; Foo::some_sub => $VAR1 = [ 4, 5, 6 ]; Compilation finished at Wed Sep 29 12:33:29

this horribly fails (please note also all those potential problems caused by UNIVERSAL::AUTOLOAD by triggering with intentionally undefined methods)

use strict; use warnings; # https://perlmonks.org/?node_id=11137026 package Base; use Data::Dumper; sub AUTOLOAD { our $AUTOLOAD; return if $AUTOLOAD =~ /::DESTROY$/; # ignore destruction * warn "$AUTOLOAD => ", Dumper \@_; } *UNIVERSAL::AUTOLOAD = \&AUTOLOAD; package Bla; *AUTOLOAD = \&Base::AUTOLOAD; # aka Bla::AUTOLOAD some_sub(1,2,3); #*Foo::AUTOLOAD = \&Base::AUTOLOAD; Foo::some_sub(4,5,6)

-*- mode: compilation; default-directory: "d:/tmp/pm/" -*- Compilation started at Wed Sep 29 12:37:45 C:/Strawberry/perl/bin\perl.exe -w d:/tmp/pm/universal_autoload.pl Name "UNIVERSAL::AUTOLOAD" used only once: possible typo at d:/tmp/pm/ +universal_autoload.pl line 15. Name "Bla::AUTOLOAD" used only once: possible typo at d:/tmp/pm/univer +sal_autoload.pl line 20. Bla::some_sub => $VAR1 = [ 1, 2, 3 ]; Use of inherited AUTOLOAD for non-method Foo::some_sub() is no longer +allowed at d:/tmp/pm/universal_autoload.pl line 28. Compilation exited abnormally with code 255 at Wed Sep 29 12:37:45

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery

update

*) added, otherwise the output is littered with all objects with undefined DESTROY methods triggering AUTOLOAD.

  • Comment on Re^9: Use of inherited AUTOLOAD for non-method is no longer allowed with Perl 5.34. (SSCCE)
  • Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11137107]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (2)
As of 2024-04-26 06:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found