3 minutes, 41 seconds
Expressions, Types, and Functions
- slide 14 : 46
Static type checking
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