7.2 Packages

If your application consists of several modules you can design it as a package. A package is a collection of modules which form a unit but allow you an individual management, e.g. updating and recompilation. A package is defined by a header module which should have the name of the package as the module name. This module then contains a declaration for the package by the function create-package, which expects as first parameter a list of the modules which belong to the package (this list must begin with the header package) and a second dummy parameter to be set to nil (this parameter is meaningful only for modules in the REDUCE kernel). Additionally the header module should contain all global declarations for the complete package, e.g. fluid, global declarations and exports and imports statements. Also, all macros, smacros used in more than one module in the package should be defined in the header module.

As long as you develop your application and frequently recompile single modules it would be practical to replace the function create-package by a loop calling load_package (please note the underscore: load-package is a different function not usable here). You then can load the complete package by one call to load_package for the header module. Example:

module alggeo; % Algebraic geometry support.  
 
 % Author: Hugo Nobody, Nirwanatown, Utopia.  
 
% create_package(’(alggeo alggeo1 alggeo2 alggeo3));  
for each x in ’(alggeo1 alggeo2 alggeo3) do load x;  
 
fluid ’(alggeo_vars!* ......);  
exports ...  
     ... and so on  
 
endmodule;  
end;

Later you can replace the load loop load by a correct create-package expression - you will then have to compile the object as one big binary with the header module as the first entry.

For compiling you use the function faslout which creates a fast loading file - see the corresponding section in the User’s manual.