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
|
When module/partition interface units are modified components are
added, removed, or altered. E.g., an interface unit may declare a class which
is modified: the ordering of its data members may change, new data members may
be added, existing data members may be removed.
When a module interface unit is modified and it's recompiled then the modified
definition replaces the old one. Consider this interface unit:
verb( export module Demo;
export
{
class Demo
{
int d_value = 100;
public:
int value() const;
};
}
)
The member function tt(Demo::value) (returning tt(d_value)) is implemented
in its own source file, and is called by tt(main):
verbinsert(-as4 examples/modifications/main.cc)
When the program is run it outputs 100. Now the module interface unit is
modified: tt(d_first) is added to the class as its first data member:
verbinsert(-as4 examples/modifications/demo/moddemo.cc)
Next tt(moddemo.cc) and tt(main.cc), are recompiled and the three object files
are linked constructing the binary program. The new binary outputs 13:
tt(value's) object file returns the first bytes of the tt(Demo) object as an
tt(int), but since the class tt(Demo) was modified those bytes no longer
contain the value 100.
Such complications are familiar: when using a traditional header declaring a
class and the class changes the organization of its data members then in
practice all source files using the class must be recompiled (and recursively:
if another class is derived from, or contains a data member of the modified
class then all source files using the other class must also be
recompiled). When using modules such recompilations are also required. The
bf(icmodmap)(1) support program has an option to recompile module (partition)
interface units depending on modified interface units and either to modify the
last write times of source files using those modules or to write their names
to a file so a build utility can recompile those module using source files.
|