Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • use base qw(Foo Bar);
    is really the combination of: require Foo; require Bar; use vars qw(@ISA); @ISA = qw(Foo Bar); Don't forget those requires!
    --
    • Randal L. Schwartz
    • Stonehenge
    • 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?
      • 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.

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

            • 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.
              • 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:
                1. Trying to load a module (and failing) where it shouldn't even have tried
                2. Not trying to load a module where it should have loaded it
                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:
                use base '+Foo';   # requires the module
                use base '-Foo';   # doesn't require the module