Front page | perl.perl5.porters |
Postings from April 2007
Re: use parent 'Some::Class' @import_list;
Thread Previous
|
Thread Next
From:
Tels
Date:
April 30, 2007 05:09
Subject:
Re: use parent 'Some::Class' @import_list;
Message ID:
200704301203.59271@bloodgate.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Moin,
On Monday 30 April 2007 01:11:50 Brandon Black wrote:
> 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.
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 "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.
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 base.pm 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,
Tels
- --
Signed on Mon Apr 30 11:49:02 2007 with key 0x93B84C15.
View my photo gallery: http://bloodgate.com/photos
PGP key on http://bloodgate.com/tels.asc or per email.
"Trying is the first step towards failure."
-- Homer Simpson
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)
iQEVAwUBRjXbL3cLPEOTuEwVAQJ82Af+Iu+0jrf3b8EmFJal608bumpW90Pzx5qT
sFBRkbqwZCQsiOPmwTmkO6RkP7rha4g0gvU45RdGcboAQvRszJq6aZrPQhK/3mqO
ce60XcMcsfmh1rZPQZjt3w+cbfc6yFA/HKKesWKp7PELnETyGOdjdt4sYcuDNAvg
qO8iS/pZL2uD1ogpM11CmhpAdJPrAg0RWHXsVYAgI1g3fAAzCgPeB+Z4KFwM/8jS
bus9hkCcUKHL/wZvipE4IFsYDqtSW/3nLkekl4/K+uhobgRCy9sq0AMuq0D3u1SA
nARJxdXQZVqSNLwKJfrTnVlSybNo+03cEGJdNImMAn4rLTLAoq1Dcw==
=7p+l
-----END PGP SIGNATURE-----
Thread Previous
|
Thread Next