Front page | perl.perl5.porters |
Postings from April 2007
Re: use parent 'Some::Class' @import_list;
Thread Previous
|
Thread Next
From:
Brandon Black
Date:
April 29, 2007 18:12
Subject:
Re: use parent 'Some::Class' @import_list;
Message ID:
84621a60704291811j4b4af276s82ee255306156a3f@mail.gmail.com
On 4/29/07, Tels <nospam-abuse@bloodgate.com> wrote:
>
> While I think it's good someone is thinking about these things, I also am
> wondering how often to you have really more than one package in the use
> base qw/.../; statement.
>
> I don't think I ever used more than use base qw/A B C/ which is mostly for
> Exporter and Dynaloader and some extra package.
>
Well, the arguments against MI are all good ones, but the fact remains
that there are lots of people out there doing MI, and lots of software
out there written in MI fashion, and perl supports MI, so it should
support it as well as it can. There are some big packages out there
that currently use MI, like DBIx::Class and Catalyst.
In any case, even in the case of "use base qw/Exporter Dynaloader
Foo/", the efficiency improvements I'm talking about will be real, and
will add up over the course of the tons of packages a complex piece of
software uses.
> Most importantly, what is the overhead of loading "base.pm", compared to the
> normal
>
> use Foo;
> @ISA = qw/Foo/;
>
> way? If you don't use the extra features present in base (fields, etc.),
> would there still be a reason to prefer it over the "manual" way?
>
Personally, I think most people are better off without "use base".
For MI, it's just:
use Foo;
require Bar;
our @ISA = qw/Foo Bar/;
You can choose require vs use to decide whether you want import called
or not, and since it is assignment rather than pushes, it's not an
efficiency issue like the individual push statements of base.pm.
However, "use base qw/Foo Bar/" has become a somewhat standard
shorthand idiom to replace the above, even though it doesn't at all
mean the same thing, and has nowhere near the same flexibility. I
really don't know if it's possible to retrofit the "assign it all once
at the end" thing onto base.pm without breaking other packages'
assumptions anyways, but I'm going to see if it's possible.
-- Brandon
Thread Previous
|
Thread Next