Advanced material
This presentation is the property of its rightful owner.
Sponsored Links
1 / 9

Advanced Material PowerPoint PPT Presentation


  • 94 Views
  • Uploaded on
  • Presentation posted in: General

Advanced Material. The following slides contain advanced material and are optional. Outline. CAT calls Generic conformance For more information, see http:// dev.eiffel.com/Comparison_of_catcall_solutions (Some of the information may be outdated…). CAT: Changed availability or type.

Download Presentation

Advanced Material

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript


Advanced material

Advanced Material

The following slides contain advanced material and are optional.


Outline

Outline

  • CAT calls

  • Generic conformance

  • For more information, see

  • http://dev.eiffel.com/Comparison_of_catcall_solutions

  • (Some of the information may be outdated…)


Cat changed availability or type

CAT: Changed availability or type

  • class PARENT

  • feature

  • f do end

  • g (a: ANY) do end

  • h: ANY

  • end

  • classCHILD

  • inherit

  • PARENT

  • redefineg

  • export{NONE} f end

  • feature

  • g (a: STRING) do a.to_upperend

  • h: STRING

  • end

Restricting export status

Covariant redefinition of argument and result type


Problems with cat

Problems with CAT

  • class APPLICATION

  • feature

  • make

  • local

  • p: PARENT

  • c: CHILD

  • do

  • create {CHILD} p

  • p.f

  • p.g (1)

  • end

  • end

Exported to NONE

Wrong argument type will lead to runtime exception


Solution to cat

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


Generic conformance

Generic conformance

  • classAPPLICATION

  • 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 := string_list

  • any_list := integer_list

  • end

  • end


Generic conformance vs changed type

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 classLIST [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.


Problems with generic conformance

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

  • end

Wrong element type


Solutions to generic conformance

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


  • Login