I always lived with the idea that "use base" was introduced with perl 5.6.0, and that we had to write
require BaseClass; # Thanks, merlyn :) use vars qw/@ISA/; @ISA = qw/BaseClass/;
is really the combination of:use base qw(Foo Bar);
Re:Missing the third part of that "use base" equiv
rhesa on 2005-06-20T12:07:55
You're right, of course. But my question was, do we need to remember that? Can't we just "use base" for the rest of our lives and forget about that archaic way of subclassing?use base is problematic
bart on 2005-06-20T14:34:45
base.pm is a mess. Occasionally it doesn't succeed in actually loading the parent module, and due to the way it's set up, it may not even complain about it too loudly, or at least not loud enough — maybe just a warning.I don't trust it. I prefer to call require or use myself, and consequentially, setting @ISA by hand.
Re:use base is problematic
rhesa on 2005-06-20T15:11:52
If base.pm really is a mess, then surely it wouldn't have been included in the core distribution.
No offence, but have you sent in a bug report with a patch, or even a failing test? I'm sure you must have hit an odd corner case. It's in the core, it's in broad use, so it must be okay for the majority of uses.
Re:use base is problematic
chromatic on 2005-06-20T16:12:47
If base.pm really is a mess, then surely it wouldn't have been included in the core distribution.I wish that were true, but sadly, it's not. Quite a few core modules have big, big messes inside.
Re:use base is problematic
rhesa on 2005-06-20T16:36:33
Well, thank you for bursting my bubble on that one;)
Any chance you could respond to my original questions? I'm really curious about it.Re:use base is problematic
bart on 2005-06-20T18:31:21
The problem, IMO, is the fact the base tries to solve two different problems in one swoop, with identical syntax. As a result: loading the module is optional. And all too often, it goes wrong. You get two types of cases where it goes wrong:If you could steer base telling it exactly where you want it to load a module or not, then there would be far less of a problem. I personally would have thought of a "+" or "-" prefix in front of the module name, for example:
- Trying to load a module (and failing) where it shouldn't even have tried
- Not trying to load a module where it should have loaded it
use base '+Foo'; # requires the module
use base '-Foo'; # doesn't require the module
I think you are confusing this with something else. The thing that was introduced with Perl 5.6 was our
, so you can say
require Foo;
our @ISA = qw( Foo );
instead of
use vars qw( @ISA );
require Foo;
@ISA = qw( Foo );