Now for variables that should not be seen outside of the module, we have my. If you wanted to hide a function, you could use a local function reference instead.
But what about packages? In C++ an anonymous namespace will localize anything to the current translation unit (source file), including class names. In Perl, a package pretty much has to have an actual name. That is, it can't be a local reference to an unnamed object (e.g. what Symbol::gensym does). I suppose the normal way of doing this is by assuming that if I named my module Foo, than no other module named Foo exists, and Foo::x, Foo::y, etc. are all OK. Big comments say that those internal namespaces are, well, internal (e.g. see documentation for Carp::Heavy). If more than one developer or a distributed team is working on the same module, then you still have to be careful about conflicts, and perhaps use an internal naming convention.
But, is there a better way? Are there any other ways, really? Is there anything proposed for Perl 6 that will better hide internal details from other code?
—John
In reply to Hiding Internal Classes ? by John M. Dlugosz
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |