http://qs321.pair.com?node_id=276995


in reply to Re: USE or Require?
in thread USE or Require?

Sigh. Perhaps I chose terms that were too specific for the attitudes I was trying to convey. You certainly choose to debate the merits of the specifics rather then the nature of the general.

My main point was not to nit pick the differences between use and require, but rather to look at the question of "Is it false lazyness to import subroutines/vars/etc into your namespace?". It's lazy in a good way because you don't have to type endless amounts of semicolons, but then it's lazy in a bad way because you don't know exactly where the subroutine came from. Obviously I favor the latter arguement, that "Foo::Baz()" is preferable to "Baz()" due to it's self documenting nature, it lets you know exactly where the subroutine is coming from and what it corresponds to.

Replies are listed 'Best First'.
Re: Re: Re: USE or Require?
by chromatic (Archbishop) on Jul 23, 2003 at 03:01 UTC

    Okay, that's a different question and worth more thought.

    I don't have a problem importing things into my namespace for three reasons:

    • I keep my code fairly short, so I don't have to import many things.
    • I tend to import only the things I really want, so the use line explicitly says what I want.
    • When I bend my second point, I only do so with well-defined idioms, such as with the Test::* modules or something like File::Path.

    I expect someone maintaining my code to be able to find the original location of functions I've imported. I try not to make it hard on that person, but I don't believe in writing un-idiomatic code because it's perceptually "self-documenting". Part of maintainability is readability and duplicate code hurts that.

Re: Re: Re: USE or Require?
by ihb (Deacon) on Jul 23, 2003 at 08:57 UTC

    I'll second chromatic and add:

    • If you ever feel like getting a drop-in replacement you'd need to do dangerous things.

    I generally dislike hardcoded things, and using a fully qualified name is no exception.

    ihb

Re: Re: Re: USE or Require?
by demerphq (Chancellor) on Jul 23, 2003 at 18:28 UTC

    I think using require is false lazyness. And the points that were made about require are very valid and pertinent to the discussion of using one over the other. IMO its use unless you have _very_ good reason to want to use require. And one of those points that is sofar unmentioned (I think) is that prototypes arent respected by code that is 'required'.


    ---
    demerphq

    <Elian> And I do take a kind of perverse pleasure in having an OO assembly language...