Nested submodules within a module are delimited by matching ‘:- module’ and ‘:- end_module’ declarations. (Note that ‘:- end_module’ for nested submodules are mandatory, not optional, even if the nested submodule is the last thing in the source file. The module name in a ‘:- module’ or ‘:- end_module’ declaration for a nested submodule need not be fully qualified.) The sequence of items thus delimited is known as a submodule item sequence.
The interface and implementation parts of a nested submodule may be specified in two different submodule declarations. If a submodule item sequence includes an interface section, then it is a declaration of that submodule; if it includes an implementation section, then it is a definition of that submodule; and if includes both, then it is both declaration and definition.
It is an error to declare a submodule twice, or to define it twice. It is an error to define a submodule without declaring it. As mentioned earlier, it is an error to define a submodule in the interface section of its parent module.
If a submodule is declared but not explicitly defined, then there is an implicit definition with an empty implementation section for that submodule. This empty implementation section will result in an error if the interface section of a submodule contains any of the following: