Closed p5pRT closed 20 years ago
base.pm contains this code:
foreach my $base (@_) {
unless (defined %{"$base\::"}) {
eval "require $base";
This normally handles loading the modules of the parents that you are making a child class inherit from. However\, my class naming looks like this:
FrontEnd FrontEnd::Tty etc
Here FrontEnd::Tty is a child of FrontEnd. If I just put "use base qw(FrontEnd)" in FrontEnd::Tty\, the parent class is not properly loaded\, and things like FrontEnd::Tty->new fail:
perl -e 'use FrontEnd::Tty; FrontEnd::Tty->new' Can't locate object method "new" via package "FrontEnd::Tty" at -e line 1.
I think it's failing like this because the code quoted earlier tries to be too smart\, and tests to see if FrontEnd is defined in perl's namespace. But it is already defined\, since "package FrontEnd::Tty" has been run. So the require line is skipped\, and things go south.
\joey@​kitenet\.net writes:
This is a bug report for perl from joey@kitenet.net\, generated with the help of perlbug 1.26 running under perl 5.00503.
----------------------------------------------------------------- [Please enter your report here]
base.pm contains this code:
foreach my $base (@_) { unless (defined %{"$base\::"}) {
eval "require $base";This normally handles loading the modules of the parents that you are making a child class inherit from. However\, my class naming looks like this:
FrontEnd FrontEnd::Tty etc
Here FrontEnd::Tty is a child of FrontEnd. If I just put "use base qw(FrontEnd)" in FrontEnd::Tty\, the parent class is not properly loaded\, and things like FrontEnd::Tty->new fail:
perl -e 'use FrontEnd::Tty; FrontEnd::Tty->new' Can't locate object method "new" via package "FrontEnd::Tty" at -e line 1.
I think it's failing like this because the code quoted earlier tries to be too smart\, and tests to see if FrontEnd is defined in perl's namespace. But it is already defined\, since "package FrontEnd::Tty" has been run. So the require line is skipped\, and things go south.
I just re-discovered this again at work today :-( The work-round is just to do the use yourself:
package FrontEnd::Tty; use FrontEnd; use base qw(FrontEnd);
But I would like to see it fixed too.
-- Nick Ing-Simmons
On Thu\, 17 Feb 2000 21:15:24 GMT\, Nick Ing-Simmons wrote:
generated with the help of perlbug 1.26 running under perl 5.00503. [...] base.pm contains this code:
foreach my $base (@_) { unless (defined %{"$base\::"}) {
eval "require $base";This normally handles loading the modules of the parents that you are making a child class inherit from. However\, my class naming looks like this:
FrontEnd FrontEnd::Tty etc
Here FrontEnd::Tty is a child of FrontEnd. If I just put "use base qw(FrontEnd)" in FrontEnd::Tty\, the parent class is not properly loaded\, and things like FrontEnd::Tty->new fail: [...] I just re-discovered this again at work today :-( The work-round is just to do the use yourself:
package FrontEnd::Tty; use FrontEnd; use base qw(FrontEnd);
But I would like to see it fixed too.
This should be fixed in the development versions.
Sarathy gsar@ActiveState.com
Migrated from rt.perl.org#2139 (status was 'resolved')
Searchable as RT2139$