in reply to Re: Module Inheritance
in thread Module Inheritance

So there we've set up Exporter to export testsub whenever Hoos is used. Also, you should require Exporter as useing it calls its own import method.
A populair belief, but not true. Sure, using 'require' prevents the import() method to be called, but that's not the only way.
use Exporter (); # Don't call import!
Less characters to type, and it gets dealt with at compile time. Why bother with require?

Abigail

Replies are listed 'Best First'.
Re: Re: Module Inheritance
by broquaint (Abbot) on Apr 29, 2004 at 13:36 UTC
    A populair belief, but not true.
    Well, it is true. You know that. It doesn't magically not call import.
    Less characters to type, and it gets dealt with at compile time. Why bother with require?
    It's one less character to type and in modules the likes of require Exporter are being implicitly being handled at compile-time anyhow (assuming they've been useed). As for the 'Why', force of habit I guess. I generally do use Module () if I don't want import to be invoked but make an exception for require Exporter. C'est la vie.
    HTH

    _________
    broquaint

      Well, it is true.
      It's not. It's not true that you should use require to prevent import to be called. It's just one way of doing so.

      As for the 'Why', force of habit I guess.
      To me it smells like cargo-cult.

      Abigail

        It's not. It's not true that you should use require to prevent import to be called. It's just one way of doing so.
        I said 'should' as it implied advice, as I was also aware of your use approach. And (to me) it's nothing to do with preventing calling import. I'm of the opinion require is appropriate because we just want to bring in Exporter's code, we're not concerned with its import method and whether it's called or not at that point, and generally the distinction between run-time and compile-time is irrelevant when one is using Exporter (since it'll generally be wrapped in an implicit BEGIN block when the module is useed) so nothing is gained by use (or lost by it, as I said, c'est la vie).
        To me it smells like cargo-cult.
        Perhaps, but seeing as how I know what I'm doing when I say require Exporter and why I'm choosing not to use Exporter (), that kinda stops cargo-cult smell right about there.
        HTH

        _________
        broquaint