SB.5 COMBINING GENERICITY AND INHERITANCE 1185 Providing unconstrained genericity Along with inheritance,it is desirable to provide a specific notation for declaring classes as generic(unconstrained). Constrained genericity For constrained genericity we can explore the same general scheme.In the matrix example: class MATRIX [G]feature anchor:RING ELEMENT [G] ...Other features as before... end -class MATRIX with ring elements now declared as deferred class RING ELEMENT [G]feature item:G put (new:G)is do item:=new end ...Other features as before .. end--class RING ELEMENT Using the same a generic parameter in two related classes,RING_ELEMENT and MATRIY,ensures type consistency:all the elements of a given matrix will be of type RING ELEMENT [G]for the same G. We can similarly make class COMPARABLE generic: deferred class COMPARABLE [G]feature item:G put (new:G)is do item:=new end ...Other features (infix "<="minimum)as before... end--class COMPARABLE The features of the class (infix "<="minimum)represent the constraints(the with routines of the Ada form).The earlier descendants become extremely simple: class INTEGER COMPARABLE inherit COMPARABLE INTEGER] creation put end (Note that this is the whole class,not a sketch with features to be added!)The same scheme immediately applies to all other variants such as STRING COMPARABLE The technique is indeed fairly simple to apply,leading to one more emulation principle:§B.5 COMBINING GENERICITY AND INHERITANCE 1185 Constrained genericity For constrained genericity we can explore the same general scheme. In the matrix example: class MATRIX [G] feature anchor: RING_ELEMENT [G] …Other features as before … end -- class MATRIX with ring elements now declared as deferred class RING_ELEMENT [G] feature item: G put (new: G) is do item := new end …Other features as before … end -- class RING_ELEMENT Using the same a generic parameter in two related classes, RING_ELEMENT and MATRIX, ensures type consistency: all the elements of a given matrix will be of type RING_ELEMENT [G] for the same G. We can similarly make class COMPARABLE generic: deferred class COMPARABLE [G] feature item: G put (new: G) is do item := new end …Other features (infix "<=", minimum) as before … end -- class COMPARABLE The features of the class (infix "<=", minimum) represent the constraints (the with routines of the Ada form). The earlier descendants become extremely simple: class INTEGER_COMPARABLE inherit COMPARABLE [INTEGER] creation put end (Note that this is the whole class, not a sketch with features to be added!) The same scheme immediately applies to all other variants such as STRING_COMPARABLE. The technique is indeed fairly simple to apply, leading to one more emulation principle: Providing unconstrained genericity Along with inheritance, it is desirable to provide a specific notation for declaring classes as generic (unconstrained)