



























































































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!




























































































Wei Le
I (^) Type is a property of program constructs such as expressions I (^) It defines a set of values (range of variables) and a set of operations on those values I (^) Classes are one instantiation of the modern notion of the type I (^) fields and methods of a Java class are meant to correspond to values and operations
Consider the assembly language fragment
addi $r1, $r2, $r
What are the types of $r1, $r2, $r3?
Consider the assembly language fragment
addi $r1, $r2, $r
What are the types of $r1, $r2, $r3?
I (^) Assembly language is untyped (MIPS assembly)
I (^) It doesnt make sense to add a function pointer and an integer in C I (^) It does make sense to add two integers I (^) But both have the same assembly language implementation!
I (^) Detect errors: I (^) Memory errors, such as attempting to use an integer as a pointer. I (^) Violations of abstraction boundaries, such as using a private field from outside a class. I (^) Help compilation: I (^) When Python sees x+y, its type systems tells it almost nothing about types of x and y, so code must be general. I (^) In C, C++, Java, code sequences for x+y are smaller and faster, because representations are known.
I (^) Rules of inference are a compact notation of if-then statements I (^) Symbol ∧ is ”and” I (^) Symbol ⇒ is ”if-then” I (^) x : T is ”x has type T”