1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
|
Modules introduce new syntax to bf(C++). In this section the new syntax is
summarized. Note that each of the following syntax specifications end in
semicolons.
Modules may define sub-components (partitions) defining facilities which
em(may) be completely inaccessible outside of the modules
themselves. Partitions are covered in section ref(PARTITIONS).
hi(export import Name:Partition;)
itemization(
itt(export module Name;)nl()
defines a emi(module interface unit). It must be specified on the source
file's first line. tt(Name) is the module's name, its module-compiled
interface unit becomes available in tt(./gcm.cache/Name.gcm);
itt(module Name;)nl()
source files implementing a module (partition) component must start with
the line tt(module Name;), where tt(Name) is the module's name.
itt(export import Name;)nl()
inside module (partition) interface units or module (partition) source
files existing modules are made available using tt(export import Name;)
specifications. Using tt(export) is optional. In module interface units
specifying tt(export) means that the exported module is also available
when sources import the module. E.g.,
verb( // module interface unit:
export module Group;
export import <iostream>;
...
// source file:
import Group;
int main()
{ // cout available via Group
std::cout << "hello world\n";
}
)
itt(export module Name:Partition;)nl()
defines a emi(module partition interface unit). It must be specified on the
source file's first line. tt(Name) is the module's name, tt(Partition) is
a em(partition) of module tt(Name). Its compiled interface unit becomes
available in tt(./gcm.cache/Name-Partition.gcm);
itt(export import :Partition;)nl()
inside module (partition) interface units or module (partition) source files
existing module partitions are made available using tt(export import
:Partition;). In module interface units using tt(export) is required,
otherwise using tt(export) is optional.
)
|