CSE-321 Programming Languages Subtyping - PowerPoint PPT Presentation

About This Presentation
Title:

CSE-321 Programming Languages Subtyping

Description:

Key Features of Object-Oriented Languages. Multiple representation ... You are all so gullible! 15. Wrong Subtyping Rules! 16. 17. 18. Subtyping for Function Types ... – PowerPoint PPT presentation

Number of Views:22
Avg rating:3.0/5.0
Slides: 27
Provided by: sungwo8
Category:

less

Transcript and Presenter's Notes

Title: CSE-321 Programming Languages Subtyping


1
CSE-321 Programming LanguagesSubtyping
???
  • POSTECH
  • May 14, 2007

2
Key Features of Object-Oriented Languages
  • Multiple representation
  • different methods of the same name
  • dynamic dispatch
  • Encapsulation
  • Only an object's own methods can see private
    data.
  • Inheritance
  • classes, subclasses, ...
  • Subtyping
  • interface, interface extension

3
Outline
  • Overview V
  • Principle of subtyping
  • Subtyping relations
  • Coercion semantics

4
Principle of Subtyping
5
Examples
6
Basic Rules
  • Reflexivity and transitivity
  • Rule of subsumption

7
Subset Semantics for Subtyping
  • Example
  • 32-bit word for nat
  • 32-bit word for int
  • 64-bit word for float

8
Outline
  • Overview V
  • Principle of subtyping V
  • Subtyping relations
  • Coercion semantics

9
Setup
10
Subtyping for Product Types
11
Subtyping for Sum Types
12
Subtyping for Function Types
13
Subtyping for Reference Types
14
You are all so gullible!
15
Wrong Subtyping Rules!
16
(No Transcript)
17
(No Transcript)
18
Subtyping for Function Types
  • Covariant in return types B and B'
  • Contravariant in argument types A and A'

19
Dereferencing ref A
20
Assigning to ref A
21
Subtyping for Reference Types
  • A B corresponds to dereferencing.
  • B A corresponds to assigning a new value.
  • Nonvariant (neither covariant nor contravariant)

22
Subtyping for Array Types
  • Array types extension of reference types
  • Subtyping for array types in Java
  • runtime overhead of dynamic tag-checks.

23
Outline
  • Overview V
  • Principle of subtyping V
  • Subtyping relations V
  • Coercion semantics

24
Coercion Semantics for Subtyping
  • Example
  • 32-bit word for int
  • 64-bit word for float

25
Coercion Subtyping Judgment
26
Coherence
  • All coercion functions for A B
  • ) exhibit the same behavior.
Write a Comment
User Comments (0)
About PowerShow.com