|
Problem:
You want to create a hierarchy of classless objects. Solution:
Use the
Discussion: Some languages have the concept of instance-based inheritance, in which objects aren't well-defined classes so much as extensions of other object instances. A root object is used as the base of the inheritance chain, and all other objects are created as empty objects inheriting from that root object. (This approach is available in perl5 via the CPAN module Class::Classless, by Sean Burke.) This is a powerful approach for situations where you don't have complete information about all the behaviors that will be expected of each object, or where there are so many possible combinations of object behavior that declaring a class for each possible combination is impractical. Note that classless objects in perl6 aren't really classless -- they are instances of the class that was used to create the root object. Issue: This approach is somewhat different from that presented in recipe 4.4, "Inheriting from Object Instances". They need to be reconciled.
|