Lecture overview -- Keyboard shortcut: 'u'  Previous page: Types [Section] -- Keyboard shortcut: 'p'  Next page: 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 12 : 46
Functional Programming in Scheme
Expressions, Types, and Functions
Types

Types plays an essential role in any programming language and any programming paradigm. In many languages types are used in the program text as constraints on variables and parameters. C, Pascal, and Java are such languages. In others, the types are inferred (somehow extracted from use of variables, parameters etc. relative to the ways the variables and parameters are used in operators and functions). ML is such a language. Yet in other languages, types are solely used to classify the values (data objects) at run time. Scheme is such a language. Thus, in Scheme we do not encounter types in the source program, but only at run time.

The notion of type is used to make programs more readable, make them run more efficient, and to detect certain errors before they cause errors in the calculation.

  • Readability

    • Explicitly typed variables, parameters and function serve as important documentation, which enhances the program understanding.

  • Efficiency

    • Knowledge of the properties of data makes it possible to generate more efficient code

  • Correctness

    • Explicit information about types in a program is a kind of redundancy against which it is possible to check expressions and values

    • Programmers usually wish to identify type errors as early as possible in the development process