corion / parent Goto Github PK
View Code? Open in Web Editor NEWEstablish an ISA relationship with base classes at compile time
Establish an ISA relationship with base classes at compile time
It seems that, because of the code in https://github.com/Corion/parent/blob/master/lib/parent.pm#L14-L17, the arglist @_
gets propagated to require'd modules.
Please, consider these test files:
==> file.pl <==
use parent qw(A B);
print "main::ISA is (@main::ISA)\n";
==> A.pm <==
print "In A, arglist was (@_), ";
@_ = qw(Foo Bar);
print "now changed to (@_)\n";
==> B.pm <==
print "In B, arglist is (@_)\n";
If I run it, I get:
$ perl -I. file.pl
In A, arglist was (A B), now changed to (Foo Bar)
In B, arglist is (Foo Bar)
main::ISA is (Foo Bar)
Notice that A.pm starts with @_
populated and @ISA
is wrong? This doesn't looks like intended behavior, is it? Modifying the code to localize @_
before the loop, I get:
$ perl -I. file.pl
In A, arglist was (), now changed to (Foo Bar)
In B, arglist is (Foo Bar)
main::ISA is (A B)
I changed the loop to this: my @filename = @_; local @_; for ( @filename ) {...}
(or even for ( my @filename = @_, local @_ ) {...}
). Inserting local @_;
inside the for
loop would prevent @_
from propagating between modules and I don't think that's necessary.
Would you consider this a legit issue? Let me know if you want a pull request. Thanks.
Hi,
As I commented on the last commit 4bf8adc related to this bug, the correction still does not work for perl without PMC AND Config modules that does not implement non_bincompat_options
method...
We encounter the case with perl-5.10.1 compiled without PMC support.
Note that, still in our case, perl -V
does not list PERL_DISABLE_PMC
in Compile-time options.
So one should add a else clause to the if (Config->can('non_bincompat_options'))
as below:
if (Config->can('non_bincompat_options')) {
...
} else {
# Test directly in options used for the compilation
$no_pmc = $Config{ccflags} =~ /-DPERL_DISABLE_PMC\b/
|| $Config{cppflags} =~ /-DPERL_DISABLE_PMC\b/;
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.