7

I have several CPAN modules that make extensive use of meta-programming to cut down on boiler-plate and to ease refactoring.

The consequence of this however is that there are many packages that get created programmatically, thus there is never a package X::Y::Z; line in the source code for CPAN to find (and then use to add the namespace to your first-come list of reserved namespaces).

So my question is if there is a preferred way of letting CPAN know about these runtime created packages. Here are the options I am currently considering:

  • Manually search down all of the packages and create a dummy pm file for CPAN to index.
  • Manually search and then update Build.PL to include them in the provides list.
  • Add some code to the meta-programming routines to keep track of which packages are used, and add a hook into to build dist to update the provides or some other section of META.yaml

The last option is currently what I am leaning towards. I'd like to know if there are any problems with this approach, or any better ways of keeping CPAN updated with the complete list of packages.

Eric Strom
  • 39,821
  • 2
  • 80
  • 152

1 Answers1

4

If I'm reading you correctly this is a non-issue, providing you don't clobber other namespaces. There is no pre-requisite to declare every namespace created, only the base namespace of your distribution and the files associated with the distribution. If you wanted to "reserve" certain namespaces, instead of creating blank .pm files, look at creating .pod files and document instead.

squeeks
  • 1,269
  • 11
  • 14
  • At least in the case of my worst offender `List::Gen` none of the runtime created packages contain any functions that an end-user should ever be calling directly. So it doesn't really make sense to provide end user documentation for them. I know it's not necessary to declare all the package names, but I figured that letting PAUSE know about them is the "best" practice. – Eric Strom Dec 01 '10 at 16:06
  • All PAUSE cares about is that the appropriate files (META.yml/.json, MANIFEST, etc) are present and correctly formatted. Once you have a namespace, what you do in it is your concern and not others unless they have permission in your namespace to contribute. For as long as you explain in your documentation that namespaces are automagically generated, you've done your bit. – squeeks Dec 02 '10 at 11:35
  • => are you sure about that? As per brian d foy's blog post ( http://www.effectiveperlprogramming.com/blog/884 ): When PAUSE assigns you a namespace as a primary maintainer, you only “own” exactly that namespace. Although Perl namespaces look like they are hierarchial, they aren’t. That is, there’s nothing in Perl that cares what namespace you use or which one your package inherits from. The XML::Simple namespaces doesn’t inherit from XML by virtue of its name. In the same way, you don’t have any permissions on Foo::Bar::Baz merely because PAUSE assigned you permissions on Foo::Bar. – Eric Strom Dec 22 '10 at 21:48