COMS W4115
Programming Languages and Translators
Lecture 15: Types
March 23, 2015

Lecture Outline

  1. Semantic analysis
  2. Types
  3. Type systems
  4. Typing in programming languages
  5. Type inference rules
  6. Type conversions

1. Semantic Analysis

2. Types

3. Type Systems

4. Typing in Programming Languages

5. Type Inference Rules

6. Type Conversions

7. Practice Problems

  1. Give some examples of typeless programming languages.
  2. The following grammar generates programs consisting of a sequence of declarations D followed by a single expression E. Each identifier must be declared before its use.
  3. 
         P → D ; E
         D → D ; D | T id
         T → int | float | T [ num ]
         E → num | id | E [ E ] | E + E
       
    Construct type expressions as in ALSU, Section 6.3.1 (pp. 371-372) for the following programs:
    1. int a; int b; a + b
    2. float[10][20] a; a[1] + a[2]
  4. Write pseudcode for a function sequiv(exp1, exp2) that will test the structural equivalence of two type expressions exp1 and exp2. Show how your function computes sequiv(array(2, array(2, int)), array(2, array(3, int))).

8. Reading





aho@cs.columbia.edu