Advanced Material The following slides contain advanced material





![Generic conformance class APPLICATION feature make local any_list: LIST [ANY] string_list: LIST [STRING] integer_list: Generic conformance class APPLICATION feature make local any_list: LIST [ANY] string_list: LIST [STRING] integer_list:](https://slidetodoc.com/presentation_image/7d1f49191e1737b804ec94f6fa28e4b3/image-6.jpg)
![Generic conformance vs. changed type class LIST [G] feature put (a: G) do end Generic conformance vs. changed type class LIST [G] feature put (a: G) do end](https://slidetodoc.com/presentation_image/7d1f49191e1737b804ec94f6fa28e4b3/image-7.jpg)
![Problems with generic conformance class APPLICATION feature make local any_list: LIST [ANY] string_list: LIST Problems with generic conformance class APPLICATION feature make local any_list: LIST [ANY] string_list: LIST](https://slidetodoc.com/presentation_image/7d1f49191e1737b804ec94f6fa28e4b3/image-8.jpg)

- Slides: 9
Advanced Material The following slides contain advanced material and are optional. 1
Outline Ø CAT calls Ø Generic conformance Ø For more information, see http: //dev. eiffel. com/Comparison_of_catcall_solutions (Some of the information may be outdated…) 2
CAT: Changed availability or type class PARENT feature f do end g (a: ANY) do end h: ANY end class CHILD inherit PARENT redefine g export {NONE} f end Restricting export status feature g (a: STRING) do a. to_upper end h: STRING end Covariant redefinition of argument and result type 3
Problems with CAT class APPLICATION feature make local p: PARENT c: CHILD do create {CHILD} p Exported to NONE p. f end p. g (1) end Wrong argument type will lead to runtime exception 4
Solution to CAT ØChanged availability (restricting export status) Ø Not allowed anymore in ECMA Eiffel ØCovariant result type Ø This is not a problem ØCovariant argument type Ø Currently checked at run-time Ø Different solutions proposed, not yet decided on a particular strategy 5
Generic conformance class APPLICATION feature make local any_list: LIST [ANY] string_list: LIST [STRING] integer_list: LIST [INTEGER] do � string_list : = any_list � string_list : = integer_list � integer_list : = any_list � integer_list : = string_list � any_list : = integer_list end 6
Generic conformance vs. changed type class LIST [G] feature put (a: G) do end first: G end interface class LIST [ANY] feature put (a: ANY) first: ANY end interface class LIST [STRING] feature put (a: STRING) first: STRING end LIST [STRING] conforms to LIST [ANY], thus the changed type in the argument and result are like a covariant redefinition. 7
Problems with generic conformance class APPLICATION feature make local any_list: LIST [ANY] string_list: LIST [STRING] do create string_list. make any_list : = string_list any_list. put (1) string_list. first. to_upper end Wrong element type end 8
Solutions to generic conformance ØNovariant conformance Ø No conformance between generics of different type Ø Used by C# ØUsage-site variance Ø Specify conformance for each generic derivation Ø Used by Java ØDefinition-site variance Ø Specify conformance for each generic class Ø Implemented by CLR 9