Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Imported subroutines

by Laurent_R (Abbot)
on Sep 16, 2013 at 21:50 UTC ( #1054338=note: print w/replies, xml ) Need Help??


in reply to Imported subroutines

I may be wrong, but my understanding is that when you use or require a module, Perl is compiling the whole module anyway, including the subroutines which are not exported, so that the only difference between exporting or not exporting a function (putting its name in @EXPORT or @EXPORT_OK) would really be updating the program namespace, which probably is not measurable. The fact that you don't export a subroutine does not mean that you don't use it, it only means that it is not intended to be used directly by the main program, but it may very well be used internally by other functions of the same module. Is this view wrong? Am I missing something?

Replies are listed 'Best First'.
Re^2: Imported subroutines
by sundialsvc4 (Abbot) on Sep 17, 2013 at 01:48 UTC

    No, I think that you are exactly correct.   The module will be compiled, regardless, if not done already.   Then, any name in @EXPORT will be added to the global namespace.   If you provide a list of routines in your use statement, they must be in @EXPORT_OK.

    Nothing will lead to any sort of performance problem.   Everything goes through a one-time “compile (on the fly)” process and, once done, never happens again (AFAIK) for the duration of the run.   If there is a performance issue in this app, “red herring ... look elsewhere.”

Re^2: Imported subroutines
by GrandFather (Sage) on Sep 18, 2013 at 03:31 UTC

    I almost never export anything from modules I write. I almost always:

    use Wibble qw();

    when I use modules. I means I have to:

    Wibble::Wobble();

    when I need to call Wobble(), but at least I know where Wobble() lives that way even minutes, or months, after I wrote the code.

    Using OO largely avoids the name space pollution problem that these measures seek to avoid without cluttering the code with explicit name space references.

    True laziness is hard work

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1054338]
help
Chatterbox?
[1nickt]: Corion HPs? ugh. I was impressed with Lenovo's gaming laptops; if it weren't for the red backlighting and general flashiness of the aesthetic, I might have gone with that. But all that was until I discovered that the Dell Precision line is still around.
[1nickt]: stevieb I don;t doubt that there's a difference. BestBuy has "consumer" models only on display.
[ambrus]: 1nickt: for some reason, these days they call every computer "gaming", even ones that gamers wouldn't buy. I've bought a keyboard that was labelled "gamer", despite that it has hard springs and seems to be way better for typing than for gaming;
[1nickt]: I though the gamers like that because they bash the keys so hard.
[ambrus]: and I've seen motherboards with no fast expansion ports for a video card but built-in hardware RAID advertized as "gaming".
LanX has a shaming laptop
[ambrus]: 1nickt: my impression is that the gamers like the softer springs, because fast reaction time is more important to them then feedback from keypresses to recognize typos.
[1nickt]: Ah, I see. I did read some gamer mag reviews, and yes, they lamented the fact that laptops with no discrete video card are sold as "gaming" hardware.

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (14)
As of 2017-03-27 13:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (320 votes). Check out past polls.