SB.6 KEY CONCEPTS INTRODUCED IN THIS APPENDIX 1187 Providing constrained genericity Along with unconstrained genericity,it is desirable to provide constrained genericity by relying on inheritance rules (through the notion of type conformance)to define constraints on permissible actual generic parameters. As a last detail,you will remember that in this scheme constrained genericity becomes the more basic facility:the unconstrained case,as in OUEUE [G],is understood as an abbreviation for OUEUE [G->ANY]where ANY denotes the class that serves as ancestor to all developer-defined classes.This has the consequence of defining precisely the operations applicable to G:those,coming from ANY,which are applicable to all classes,including general-purpose features such as clone,print and equal. The introduction of constrained genericity provides the final touch to the delicate combination of inheritance and genericity detailed in this chapter.I hope that you will find the result consistent,elegant,and minimal in the sense that although no component of the edifice is redundant (as it should indeed always be immediately clear,for any particular circumstance,which of the various possibilities is the appropriate one),removing any one of them would lead us to one of the situations that we found unacceptable or unpleasant in the earlier sections of this appendix:unacceptable because we cannot do what we want. as when we were trying to emulate inheritance with genericity;unpleasant when we could do what we want but at the price of such complications as the use of artificial wrapper classes and inefficient wrapper objects.The proper combination of inheritance and genericity should help make our choices not only acceptable but pleasant too B.6 KEY CONCEPTS INTRODUCED IN THIS APPENDIX Both genericity and inheritance aim to increase the flexibility of software modules. .Genericity is a static technique,applicable in O-O and non-O-O contexts,permitting the definition of modules parameterized by types. There are two forms of genericity:unconstrained,imposing no requirements on the parameters;constrained,requiring parameters to be equipped with specific operations. Inheritance permits incremental module construction,by extension and specialization.It opens the way to polymorphism and dynamic binding. It does not seem possible to obtain the power of inheritance through genericity Pure inheritance can be used to emulate genericity,but at the expense of heaviness in expression,performance penalties(mostly space)and type difficulties. A good compromise is to combine the full power of inheritance and redefinition with genericity,at least in its unconstrained form.This is achieved by permitting classes to have generic parameters. It is also desirable to provide constrained genericity,which relies on the notion of type conformance,itself following from inheritance.Unconstrained genericity can then be viewed as a special case,using the universal class ANY as the constraint. The resulting construction seems elegant and minimal.§B.6 KEY CONCEPTS INTRODUCED IN THIS APPENDIX 1187 As a last detail, you will remember that in this scheme constrained genericity becomes the more basic facility: the unconstrained case, as in QUEUE [G], is understood as an abbreviation for QUEUE [G –> ANY] where ANY denotes the class that serves as ancestor to all developer-defined classes. This has the consequence of defining precisely the operations applicable to G: those, coming from ANY, which are applicable to all classes, including general-purpose features such as clone, print and equal. The introduction of constrained genericity provides the final touch to the delicate combination of inheritance and genericity detailed in this chapter. I hope that you will find the result consistent, elegant, and minimal in the sense that although no component of the edifice is redundant (as it should indeed always be immediately clear, for any particular circumstance, which of the various possibilities is the appropriate one), removing any one of them would lead us to one of the situations that we found unacceptable or unpleasant in the earlier sections of this appendix: unacceptable because we cannot do what we want, as when we were trying to emulate inheritance with genericity; unpleasant when we could do what we want but at the price of such complications as the use of artificial wrapper classes and inefficient wrapper objects. The proper combination of inheritance and genericity should help make our choices not only acceptable but pleasant too. B.6 KEY CONCEPTS INTRODUCED IN THIS APPENDIX • Both genericity and inheritance aim to increase the flexibility of software modules. • Genericity is a static technique, applicable in O-O and non-O-O contexts, permitting the definition of modules parameterized by types. • There are two forms of genericity: unconstrained, imposing no requirements on the parameters; constrained, requiring parameters to be equipped with specific operations. • Inheritance permits incremental module construction, by extension and specialization. It opens the way to polymorphism and dynamic binding. • It does not seem possible to obtain the power of inheritance through genericity. • Pure inheritance can be used to emulate genericity, but at the expense of heaviness in expression, performance penalties (mostly space) and type difficulties. • A good compromise is to combine the full power of inheritance and redefinition with genericity, at least in its unconstrained form. This is achieved by permitting classes to have generic parameters. • It is also desirable to provide constrained genericity, which relies on the notion of type conformance, itself following from inheritance. Unconstrained genericity can then be viewed as a special case, using the universal class ANY as the constraint. • The resulting construction seems elegant and minimal. Providing constrained genericity Along with unconstrained genericity, it is desirable to provide constrained genericity by relying on inheritance rules (through the notion of type conformance) to define constraints on permissible actual generic parameters