Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re^3: Namespaces contiguous in the entirety

by Tanktalus (Canon)
on Sep 28, 2005 at 23:20 UTC ( [id://495943]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Namespaces contiguous in the entirety
in thread Namespaces contiguous in the entirety

That's actually kind of my point. Convention says this is what you're supposed to do. However, convention also allows for alternatives. Convention says that each package appears once, at the top of a .pm file of the same name where ::'s are converted to directory separators. Which means that you should only have one package per file, and that you should never overlap with others' packages.

In reality, there can be valid reasons for bucking convention. Packages that are too small to worry about separate files is a valid one. Hiding a package is another one - e.g., how mirod hides XML::Twig::Elt inside the XML/Twig.pm. Although in this case, it may be partly because XML::Twig and XML::Twig::Elt are so tightly intertwined that there could be fun times in trying to compile them in separate units. Other cases may have tightly tied packages where using the wrong one first can't resolve BEGIN blocks appropriately. Or other tightly tied packages where the other packages would take longer to locate on disk than is worth it.

I really don't have a problem with the OP's suggestion. As long as there is a clean and easy way to turn it off when I know what I'm doing. Such as what TimToady suggests.

use CGI::Application; class CGI::Application is also { # stuff we want to add to the CGI::Application namespace. };
This says, "Yes, I know there is already a CGI::Application, but I'm the human, and you're the dumb computer, so do what I tell you." Well, that's what it says if I do it. It might not be so snarky if others do it ;-) I don't have an issue with this - the extra typing required for the rare time I do it seems like a reasonable trade-off.

I'm not sure if there will be any perl 6 diagnostics for packages classes in the wrong file, though, as I had suggested to the OP.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (3)
As of 2024-04-25 07:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found