This package is compile-time tailorable to a particular application. This tailoring is done without editing the source code of the package's interface or implementation. This is easy if only one version of the package is to be part of the application, and somewhat more involved if two or more versions of the package are to be part of the application. In the former case the procedure is:
(1) create a ParticularList definitions module, which must define Item, nullItem, and Compare as follows:
DIRECTORY Environment USING [Comparison], ... ;
ParticularList: DEFINITIONS = BEGIN
Item: TYPE = <any type specification>;
nullItem: Item = <any constant Item value; if Item is a REF type, use NIL>;
Compare: PROC [l1, l2: LIST OF Item] RETURNS [Environment.Comparison] ... ;
Compares the two Items contained in l1.first and l2.first (l1, l2 are never NIL)
Result = less means l1.first < l2.first, etc. May be defined inline.
END.
(2) Compile the ParticularList module created in step 1.
(3) Compile ListSort (this module).
(4) Compile OnlineMergeSortImpl (the implementation of this module).
(5) Clients of the package use the ListSort.bcd created in step 3, and the application binds in the OnlineMergeSortImpl.bcd created in step 4.
In case of multiple versions of the package within a single application, the different versions of modules ParticularList, ListSort, and OnlineMergeSortImpl must have distinct bcd names. The different ParticularList source files must also have distinct names. Since in this case the module name <-> file name correspondence is not one-to-one, compiler command-line parameterization controls the different versions, as in:
(3') xxxListSort ← ListSort[ParticularList: xxxParticularList]
(4') xxxOnlineMergeSortImpl ← OnlineMergeSortImpl[ListSort: xxxListSort]