We describe a programming environment for developing generic mathematical libraries with high-performance requirements. The environment is based on the concept of functors as pioneered by SML, but also on a number of original concepts; we especially focus on the combination of the functor-based programming principle with software engineering principles in large development projects. The generated code is highly efficient and can be easily embedded into foreign application environments.
The features of the programming environment include:
Module interfaces are described by axiomatic specifications that do not only represent syntactic interfaces but also semantic properties (input and output conditions). These properties do not only give precise meanings to modules but are also (with restrictions) used to automatically generate assertions and also default implementations. Specifications may be parameterized to describe functor interfaces; a specification (i.e., also a module) may contain modules as components.
Functors are parameterized over other modules with denoted specifications and return a result module. Contents of other modules may be referenced by qualification or by import into the current environment; multiple functions with the same name but different type interfaces may coexist in the same environment (overloading). Types have constructors and destructors associated to them that are invoked when corresponding values/variables are declared. No direct reference to any builtin type is required, all language constructs can be used in a generic fashion.
Functors may be instantiated with modules (i.e., the results of other functors) in order to yield executable results. The instantiation system forwards all implementation information transparently to the code generator such that e.g. function code may be inlined and special code may be generated for machine-level operations. The generated C++ code is compiled with the native machine compiler and has the same performance as manually written code.
A sophisticated package handling concept allows to group specifications, functors, module descriptions, and also packages into hierarchies of program units. The environment of program units visible in a package and thus the access to other program units may be explicitly controlled, also may the contents of other packages be imported and thus virtual package environments be constructed.
The system utilizes an efficient dependence control mechanism which frees the user from any concern about the maintenance of relationships between different program units. This is of particular importance, since a functor is in general the source of different module instantiations on which in turn other instantiations may depend. Likewise, a permission control mechanism allows to share the same package tree by multiple software developers without need for duplication of module instantiations.
The system is currently in transit from alpha to beta state; a corresponding mathematical sample library is under development. We will further develop the system in order to support revision control and to include higher-order functors (functors as components of modules and functors parameterized over other functors).