¥To
define a method m on a composite class like DeptDirectory, we follow the same process as we would in defining a method on a union class, with one new wrinkle.
In the variants that refer to the composite
class (have fields of composite class type),
computing m for this will usually involve delegating the task of computing m for the embedded references to the composite class.
¥In
our DeptDirectory
example, the only embedded
reference to DeptDirectory
in variant subclasses is the rest field
in NonEmpty.
¥