280 likes | 295 Views
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.
E N D
CSE-321 Programming LanguagesSubtyping 박성우 POSTECH April 10, 2006
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
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!
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, ...
Outline • Overview V • Principle of subtyping • Subtyping relations • Coercion semantics
Basic Rules • Reflexivity and transitivity • Rule of subsumption
Subset Semantics for Subtyping • Example • 32-bit word for nat • 32-bit word for int • 64-bit word for float
Outline • Overview V • Principle of subtyping V • Subtyping relations • Coercion semantics
Subtyping for Function Types • Covariant in return types B and B' • Contravariant in argument types A and A'
Subtyping for Reference Types • A·B corresponds to dereferencing. • B·A corresponds to assigning a new value. • Nonvariant (neither covariant nor contravariant)
Subtyping for Array Types • Array types = extension of reference types • Subtyping for array types in Java • runtime overhead of dynamic tag-checks.
Outline • Overview V • Principle of subtyping V • Subtyping relations V • Coercion semantics
Coercion Semantics for Subtyping • Example • 32-bit word for int • 64-bit word for float