7.1 Program modules

It is a good practice to design a complex program group in separate modules each residing in a separate source file. You can use the REDUCE statement pair module - endmodule to reflect this structure. A module has a name which often will be identical with its source file (without extension, of course). This correspondence is not essential, but is very practical for the daily work. As a side effect module switches automatically to symbolic mode during input and endmodule switches back to the original mode. A typical module in a file would look like

module alggeo1; % Primitives for algebraic geometry.  
 
 % Author: Hugo Nobody, Nirwanatown, Utopia.  
 
 .......   the symbolic mode code  
 
endmodule;  
end;

If this module resides in a file alggeo1.red it can either be read into a REDUCE session by

  in "alggeo1.red"$

or it can be compiled to a fast loadable binary by

  faslout "alggeo1";  
  in "alggeo1.red"$  
  faslend;

You then can load this module by load alggeo.

Although REDUCE currently does not yet rely exclusively on declarations exports and imports , these should be used in order to be safe for the future. exports should name all entry points which the module offers for external access and imports is the list of modules or packages which the module needs at run time or during compilation.