Lecture overview -- Keyboard shortcut: 'u'  Previous page: Type checking -- Keyboard shortcut: 'p'  Next page: An example of type checking -- Keyboard shortcut: 'n'  Lecture notes - all slides and notes together  slide -- Keyboard shortcut: 't'  Textbook -- Keyboard shortcut: 'v'  Help page about these notes  Alphabetic index  Course home    Lecture 2 - Page 14 : 46
Functional Programming in Scheme
Expressions, Types, and Functions
Static type checking

We here make the distinction between explicit type decoration and implicit type inference, and explain the principled difference.

There are two main kinds of static type checking: explicit type decoration and implicit type inference

Let us study the expression (+ x (string-length y))

  • Explicit type decoration

    • Variables, parameters, and others are explicitly declared of a given type in the source program

    • It is checked that y is a string and that x is a number

  • Implicit type inference

    • Variables and parameters are not decorated with type information

    • By studying the body of string-length it is concluded that y must be a string and that the type of (string-length y) has to be an integer

    • Because + adds numbers, it is concluded that x must be a number