Separate sub-modules are declared using ‘:- include_module Modules’ declarations. Each ‘:- include_module’ declaration specifies a comma-separated list of sub-modules.
:- include_module Module1, Module2, ..., ModuleN.
Each of the named sub-modules in an ‘:- include_module’ declaration must be defined in a separate source file. The mapping between module names and source file names is implementation-defined. (For a module named ‘foo.bar.baz’, The University of Melbourne Mercury implementation requires the source to be located in a file named foo.bar.baz.m, bar.baz.m, or baz.m.) The separate source file must contain the declaration (interface) and definition (implementation) of the sub-module. It must start with a ‘:- module’ declaration which matches that in the ‘:- include_module’ declaration in the parent, followed by the interface and (if necessary) implementation sections, and it may optionally end with a ‘:- end_module’ declaration. (Note: the module names in the ‘:- module’, ‘:- end_module’, and ‘:- include_module’ declarations need not be fully-qualified. However, if the file name used for a particular module does not include all the module qualifiers, then the University of Melbourne Mercury implementation requires the module name in the ‘:- module’ declaration for that module to be fully qualified.)
The semantics of separate sub-modules are identical to those of nested sub-modules. The procedure to transform a separate sub-module into a nested sub-module is as follows:
:- module x. :- interface. :- include_module y. :- end_module x.
is equivalent to
:- module x. :- interface. :- module y. % interface section of module ‘y’ :- end_module y. :- implementation. :- module y. % implementation section of module ‘y’ :- end_module y. :- end_module x.