Re: Namespace for local/internal modules?
by tobyink (Canon) on May 23, 2012 at 22:50 UTC
|
Indeed, Local:: is the namespace you should use for local things. There are a handful of modules in this namespace if you search CPAN, but if you look closely they're mostly in "examples" directories, not in "lib", so will usually not get installed.
local::lib and some of its friends are unfortunate. Technically they're not violating the rule, but on case-insensitive filesystems they might as well be.
If you have a CPAN ID yourself, you can always use your own CPAN ID (in all caps) as a namespace. Many people regard that as a namespace that 100% belongs to the owner of the CPAN ID. That is, I could release a module called TOBYINK::Monkey, but for anyone else to do so would be outrageous.
perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'
| [reply] [Watch: Dir/Any] [d/l] |
|
Thanks for the clarification about Local::. And I did not know about using CPAN ID's as top level namespaces. That seems more ideal since others can get at it.
(One of the reasons I haven't released some of my better modules is that, especially for mathematical modules, there's no good name other than the thing being implemented like "Math::CholeskyDecomposition" or whatever, but there are multiple ways of doing math in perl (Math::GSL, PDL, Math::Matrix, straight vanilla perl, etc), so I don't want to usurp the namespace.)
| [reply] [Watch: Dir/Any] |
|
"If you have a CPAN ID yourself, you can always use your own CPAN ID (in all caps) as a namespace." -- tobyink.
Blech! Aesthetic reasons alone are too strong for me then not to use "Local" instead.
| [reply] [Watch: Dir/Any] |
|
| [reply] [Watch: Dir/Any] |
|
| [reply] [Watch: Dir/Any] [d/l] |
|
|
|
Re: Namespace for local/internal modules?
by Anonymous Monk on May 24, 2012 at 09:35 UTC
|
perlmodlib says If developing modules for private internal or project specific use, that will never be released to the public, then you should ensure that their names will not clash with any future public module. You can do this either by using the reserved Local::* category or by using a category name that includes an underscore like Foo_Corp::*. | [reply] [Watch: Dir/Any] |
Re: Namespace for local/internal modules?
by chrestomanci (Priest) on May 25, 2012 at 09:32 UTC
|
Similar to the idea of using you CPAN id, you could also use your company name as the root of your namespace. Most of companies I have worked for in the past five years have done that, and it works fairly well.
Obviously if you work for a massive corporation you many find that your have replaced clashes at the root of the namespace with clashes at the next level down, where your version of <company>::Math conflicts with another team half a continet away.
The other issue would be if you work for an internet company where the public are creating both authorised an un-authorised API interfaces to your publicly facing systems, so if you work for Google, then it would probably not be a good idea to use that as a namespace root, and you will conflict with other people creating Google APIs.
| [reply] [Watch: Dir/Any] |
|
| [reply] [Watch: Dir/Any] |