I'm using Moops
and I'd like something like this to work:
use Moops;
class A {
fun f {
print "yay,f!\n";
}
}
class B extends A {
fun g {
f();
}
}
B->g(); # should print 'yay, f!'
Instead this yields:
Undefined subroutine &B::f called at static-functions-lexical-scope.pl line 11.
I can "fix" this by inheriting from Exporter
in A
and a use
statement in B
like so:
class A extends Exporter {
our @EXPORT = qw(f);
fun f {
print "yay,f!\n";
}
}
class B extends A {
use A;
fun g {
f();
}
}
This seem a bit unwieldy, but it gets worse if A
is defined in another file. Then I'd have to add a second use A
(require
won't do) outside of B
like so:
use A;
class B extends A {
use A;
fun g {
f();
}
}
Is there a way to make lexical inclusion (of exported) functions work more elegantly?