cons-discuss
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Packages and cons


From: Johan Holmberg
Subject: Re: Packages and cons
Date: Wed, 18 Jul 2001 14:06:11 +0200 (MEST)

On Wed, 18 Jul 2001, Frank Thomas wrote:
>
> I'd suggest "use Exporter;" instead of "require Exporter;" because it's
> less overhead.
>
> Bye
>       Frank
>

I don't know if it matters much, but I thought that
"require Exporter" was the idiomatic way to do this,
as recommended by the Exporter-manpage:

    
http://aspn.activestate.com/ASPN/Reference/Products/ActivePerl/lib/Exporter.html

As I understand it, there are two differences between

    use Exporter;
and
    require Exporter;

1) "require" happens at runtime, "use" at compile time

2) the "use" line also tries to "import" symbols from the other
   package (in this case Exporter)


So if there is any difference in overhead, I think that "require"
would win since no call to "import" is done.

If your line

    use Exporter;

was changed to

   use Exporter ();

the only remaining difference would be compile-time versus run-time.
To quote from the documentation (perldoc -f use):

> If you don't want your namespace altered, explicitly supply
> an empty list:
>
>    use Module ();
>
> That is exactly equivalent to
>
>    BEGIN { require Module }
>

But I see no point in doing otherwise than what the documenation of
Exporter recommends.

None of this matters much,
I just felt for looking things up in the documenation ...

/johan





reply via email to

[Prev in Thread] Current Thread [Next in Thread]