





























Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!






























Lecture 16 (no lecture 15) Dr. Sean Peisert – ECS 142 – Spring 2009 1
Midterm and Parser grades this week...
< 3 weeks to go on project 3 2
is read: “Under the assumption that variables have the types given by O, it is provable that the expression e has the type T. 4
5 i is an integer
O ⊢ e 1 : Int O ⊢ e 2 : Int O ⊢ e1 + e 2 : Int
7 i is an integer
⊢ e 1 : Int ⊢ e 2 : Int ⊢ e1 + e 2 : Int
8
10
Consider the cool expression: let x : T 0 in (let y : T 1 in Ex,y) + (let x : T 2 in Fx,y)
(where Ex,y and Fx,y are some Cool expression that contains occurrences of “x” and “y”)
Scope
of “y” is Ex,y
of outer “x” is Ex,y
of inner “x” is Fx,y
This is captured precisely in the typing rule 11
Typing Example Diagram 13
14
Subtyping 16
An object of type X could be used when one of type Y is acceptable, or equivalently:
X ≤ Z if X ≤ Y and Y ≤ Z
17
Expressiveness of Static Type Systems 19
Dynamic and Static Types 20
Even languages that are not statically typed have the notion of dynamic type
A compile-time notion.