Let's imagine that I wrote a module for importing packages. Among other
features it allows to alias long package name to something shorter. It
is realised as constant subrouine returning real package name.
Something like:
use package 'Foo::Bar/Bar';
/Bar part declares alias Bar for Foo::Bar. Now I can write Bar->new
instead of Foo::Bar->new. (I know that defining alias subroutines like
Bar can cause problems at a distance, that's why they are lexical by
default thanks to builtin::export_lexically.) It works because Perl
allows to specify class names in a few ways:
Foo::Bar->new;
'Foo::Bar'->new;
Foo::Bar::->new;
Bar->new; # Early defined subroutine
But the problem is that :isa class attribute of new OOP system accepts
only Foo::Bar::Baz form. I can't inherit using alias:
use feature 'class';
use package 'Foo::Bar::Baz/Baz';
class Foo::Baz :isa(Bar);
It dies:
Can't locate Bar.pm in @INC (you may need to install the Bar module) ...
It would be useful for me if above mentioned class specification forms
was supported by :isa attribute (and by similar attributes, :does comes
to mind). It also would be into line with the rest of the language. Is
it provisioned to do so?
--
Ivan Vorontsov <ivrntsv@yandex.ru>
features it allows to alias long package name to something shorter. It
is realised as constant subrouine returning real package name.
Something like:
use package 'Foo::Bar/Bar';
/Bar part declares alias Bar for Foo::Bar. Now I can write Bar->new
instead of Foo::Bar->new. (I know that defining alias subroutines like
Bar can cause problems at a distance, that's why they are lexical by
default thanks to builtin::export_lexically.) It works because Perl
allows to specify class names in a few ways:
Foo::Bar->new;
'Foo::Bar'->new;
Foo::Bar::->new;
Bar->new; # Early defined subroutine
But the problem is that :isa class attribute of new OOP system accepts
only Foo::Bar::Baz form. I can't inherit using alias:
use feature 'class';
use package 'Foo::Bar::Baz/Baz';
class Foo::Baz :isa(Bar);
It dies:
Can't locate Bar.pm in @INC (you may need to install the Bar module) ...
It would be useful for me if above mentioned class specification forms
was supported by :isa attribute (and by similar attributes, :does comes
to mind). It also would be into line with the rest of the language. Is
it provisioned to do so?
--
Ivan Vorontsov <ivrntsv@yandex.ru>