Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Namespace Pollution

by Necos (Friar)
on May 06, 2003 at 22:52 UTC ( [id://256066]=note: print w/replies, xml ) Need Help??


in reply to Namespace Pollution

I personally feel that the user of a module should be able to choose whether or not to import functions into their namespace. What if someone writes a function called 32_bit_shift(), and I don't know about it, so I write a function with the same name. Which one gets called (I don't even know, because I try to pick names that won't be used)? Does perl generate an error? I've been lucky enough not to be bitten by conflicting function names.

I guess no importing is one of the reasons to use OO. Then, even if you have conflicting function names, Perl takes care of which to call (you did bless your objects properly, didn't you?). The one thing that urks me is the libwin32 series of modules export a ton of constants without even asking me. It's a good thing that all of those constants are the same across modules (and consistently valued too), or there would be tons of problems. It's also a good thing that those constants are documented, or someone might create a constant that happens to step on another constant's feet. I think that's one thing you forgot to mention: documentation. A module user should be able to import what they want, and not be forced to take anything he (or she) doesn't want or need. I think it's nicer that way.

Theodore Charles III
Network Administrator
Los Angeles Senior High
email->secon_kun@hotmail.com
perl -e "map{print++$_}split//,Mdbnr;"

Replies are listed 'Best First'.
Re^2: Namespace Pollution (colliding imports)
by Aristotle (Chancellor) on May 07, 2003 at 00:23 UTC
    $ perl -we'sub x { &foo } sub x { &bar }' Subroutine x redefined at -e line 1.
    You won't get a heads-up for multiple imports to the same symbol name, though.

    Makeshifts last the longest.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://256066]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (7)
As of 2024-04-18 13:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found