During the long time of polymake development several perl modules were created which have nothing to do with polytopes or some other
mathematical objects. Their aim is to accelerate the development and increase the performance of both the polymake core and the
application code. If you are going to develop non-trivial rule routines in perl or create an interface to a new visualization
engine, you should have a glance at the following chapters, as some of the components presented here have an impact on every
piece of perl code included in polymake.
the namespaces extension allows to import symbols (variables and subroutines) in C++
like manner, and it gives the use of nested packages more sense than it normally has in perl. Since the namespace mode is
automatically enabled for all rulefiles and perl modules in polymake, you should get acquainted with it just to prevent
unpleasant surprises.
overloaded functions resemble the C++ polymorphic function overloading, and integrate
this with the user preference handling in a natural way.
Struct package helps to build object classes with very quick data access and automatically defined
constructors. You must learn this at least if you design new graphical primitives for the visualization.
If you create an object $t = new Poly::Tempfile and generate the temporary file names using it as a prefix
(like "$t.in" or "$t.out"), then you don't need to take care of there files - they will be deleted
as soon as the object $t is destroyed.
This solution is exception-safe; however, there is a little trick: if polymake was started with -d
option, and the destructor of $t is called during the exception propagation (stack unwind), then the files are not
deleted, and a warning is issued. The reason for this behavior is that it could be the wrong contents of one of the temporary
files that caused the exception, thus it gives the developer a chance to find the error.
In standard perl, if you try to use a reference as a hash key, it gets converted to a string containing a hexadecimal address
of the object pointed at by the reference. Retrieving the data later on, you just get that silly string, and you can't access
the object any more.
The hash arrays in polymake preserve the reference nature of the keys: the results of each, keys, and %hash
in the list context will contain valid references. But it is not allowed to mix the reference and non-reference keys in the
same hash. An attempt to do this raises an exception.
push %hash, %another_hash, ...;
This expression is forbidden in standard perl. In polymake it merges the hashes in an efficient way, avoiding rather
expensive recomputation of the hash function for each included element.