develooper Front page | perl.perl5.porters | Postings from April 2007

Re: use parent 'Some::Class' @import_list;

Thread Previous | Thread Next
April 30, 2007 05:09
Re: use parent 'Some::Class' @import_list;
Message ID:
Hash: SHA1


On Monday 30 April 2007 01:11:50 Brandon Black wrote:
> On 4/29/07, Tels <> 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.

I think MI means Multiple Inheritance? I am not against MI, since I used it 
myself :)

> 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.

I don't dispute your claim (as I a ignorant of the inner details), I was 
just asking what would be the threshold to use "base" over the manual 
method, as seen from an authors point.

No doubt your work is important and you know much better than anyone else 
what's "worth" and what not :)

> > Most importantly, what is the overhead of loading "", 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

Ah ok. I have used that anyways, on the thinking of "save the loading of 
base". It's probably irrelevant since almost anything else you use will 
load base, anyway, but it's a start. Also, Perl subroutine calls are 
somewhat expensive (compared to almost any other operation like array 
assigns, hash lookups etc.), and if you got a ton of them at compile-time, 
it results in increased loading time for fire-once scripts. That stuff can 
add, especially since base's import() method does a bootload of things more 
than just @ISA = qw/Foo/;

> 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 without breaking other packages'
> assumptions anyways, but I'm going to see if it's possible.

Yeah, and is it really breakage if nobody looks at the splinters? :-)

All the best,


- -- 
 Signed on Mon Apr 30 11:49:02 2007 with key 0x93B84C15.
 View my photo gallery:
 PGP key on or per email.

 "Trying is the first step towards failure."

  -- Homer Simpson
Version: GnuPG v1.4.2 (GNU/Linux)


Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About