The perl namespaces extension is designed as replacement of the standard means of declaring and importing symbols, such as the pragma use strict 'vars' and Exporter interface for modules. It makes the symbol lookup rules more similar to those in C++ :
Lexical variables (my) are not affected by this extension. our declarations are not compatible with the namespaces and should be avoided.
The global namespace main:: is purposely left aside as it contains many special variables (such as $_ or %ENV) which are automatically visible from all packages, and it would be absolutely silly to require them be explicitly declared. Some other special package-specific variables, such as @INC, $AUTOLOAD, or $a and $b in a sort block, may also be used without declaration.
The namespace extension is implemented as a special compilation mode. It can be enabled and disabled for each lexical scope, just like use strict. Each package activated during the namespace compilation mode (with the package statement) is treated later as using namespaces, even if other parts of it are compiled in the standard, non-namespace mode. Mixing of both modes in one package is not a very good practice, however, as it could lead to unexpected exceptions caused by undeclared variables.
Each reference to a variable, both reading and writing, is first checked whether it refers to a declared or imported variable. If not, and the name is unqualified, then a declared variable with this name is looked up in all packages comprising the lookup list, as explained above. If found, the variable is imported into the current package. Otherwise an exception is raised. A qualified variable name is only checked to be pre-declared, if not, an exception is raised as well.
The lookup operation is performed once per variable and package; the declaration check is performed once per variable and each expression (script line) using it which was ever executed. This way the performance penalty is constant and comparable to that of the traditional import mechanism.
Unqualified subroutine calls are resolved in the same manner, but in the case of a failure no special exception is raised, since it will be done by the perl interpreter itself. Taking a subroutine reference \&abc involves the lookup too. There is also a special function namespaces::lookup_sub('package_name', 'sub_name') returning the code reference or undef if the lookup fails.
do 'FILENAME' and eval '...' statements, as well as s///e search-and-replace operators, re-establish the namespace environment for the duration of the expression compilation.
All rulefiles and perl modules defined in the application-specific perllib subdirectories are compiled with namespace mode enabled, due to the following statement automatically prepended to each source file:
use namespaces 'Apps::APPLICATION_NAME';
If an application imports polymake modules, their packages 'Modules::MODULE_NAME' are also included in the lookup list.
Finally, all applications and modules import everything from the package Poly, which contains some useful little functions like min and max.