ABSTRACT

Data have not only values but also types, which have a hierarchical classification and in principle can be arbitrarily complicated. In compiled languages, such as C, C++, and Java, variables can normally hold data of only a specific type (which might be a union of simpler types), so the type of every variable must be declared before that variable can be used. In interpreted languages, such as LISP, Maple, and many other computer algebra languages, this is not the case and variables can hold data of any type, which can change during the execution of a program. In such languages, the type is associated with the data and not with the variables. Hence, the use of data types is more subtle and can be introduced much later in a programming course. (Data types are the last fundamental programming concept to be introduced in this book.)

The concept of data types is still important in interpreted languages although their role is different from that in compiled languages: in an interpreted language the type of the data assigned to a variable is tested after assignment whereas in a compiled language it is prescribed before assignment. Data types are used for two purposes in interpreted languages: either to ensure that intended operations are well defined or to decide what operations to perform. A value can have type information at many levels; for example, the value of a variable might be a list, whose elements are sets, whose elements are polynomials, whose coefficients are rational numbers, and whose indeterminate is a particular symbol.