1 / 28

Object-Oriented Languages: Subtyping, Coercion, and Semantics

This announcement provides revised assignment details, introduces a new course, and explores the key features of object-oriented languages such as multiple representation, encapsulation, subtyping, and inheritance. It also discusses the principle of subtyping, basic rules, subset semantics, and coercion semantics for various types.

childersc
Download Presentation

Object-Oriented Languages: Subtyping, Coercion, and Semantics

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. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CSE-321 Programming LanguagesSubtyping 박성우 POSTECH April 10, 2006

  2. Announcement 1 • Assignment 6 handout has been revised. • no change to the problem • slight reorganization of structures • use em-cml.sml instead of eval.sml. • Assignment 5 has been regraded. • partial points for a wrong sequence of reductions but a correct result

  3. Announcement 2 • CSE-431 Logic in Computer Science • to be offered this fall • will look at the very foundation of computer science • will be more FUN than CSE-321 PL! • The quorum is 5, so I need at least 3 of you to sign up for this course!

  4. 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. • Subtyping • interface, interface extension • Inheritance • classes, subclasses, ...

  5. Outline • Overview V • Principle of subtyping • Subtyping relations • Coercion semantics

  6. Principle of Subtyping

  7. Examples

  8. Basic Rules • Reflexivity and transitivity • Rule of subsumption

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

  10. Outline • Overview V • Principle of subtyping V • Subtyping relations • Coercion semantics

  11. Setup

  12. Subtyping for Product Types

  13. Subtyping for Sum Types

  14. Subtyping for Function Types

  15. Subtyping for Reference Types

  16. You are so gullible, so stupid, so ridiculous!

  17. Wrong Subtyping Rules!

  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

More Related