Lecture 2 - Page 14 : 46
Functional Programming in Scheme
Expressions, Types, and Functions
* Lisp and Scheme
Lisp
Scheme
* Expressions and values
Expressions, values, and types
Examples of expressions and their values
Evaluation of parenthesized expressions
Arithmetic expressions
Equality in Scheme
The read-eval-print loop
* Types
Types
Type checking
Static type checking
An example of type checking
Types in functional programming languages
* Lists
Proper lists
Symbolic expressions and improper lists
Practical list construction
List functions
Association lists
Property lists
Tables as lists of rows
Programs represented as lists
* Other Data Types
Other simple types
Vectors
Strings
* Definitions
Definitions
* Functions
The function concept
Lambda calculus
Functions in Scheme
Function objects
Functions as first class values
Anonymous functions
Lambda expressions in Scheme
Optional parameters of Scheme functions (1)
Optional parameters of Scheme functions (2)
Closures
Function definition in Scheme
Simple web-related functions (1)
Simple web-related functions (2)
Function exercises
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