- A data type is defined by what you can do to things of
that type.
- Scheme makes all types first class so they all share 4
properties. They can be:
- given a name (using lambda, define,
let, etc.)
- passed to a procedure as an argument
- returned as a value from a procedure
- put into a data structure (e.g. a pair or a list)
- Special additional operations define data types.
- numbers have the arithmetic operations.
- strings havestring-length, string-ref, and
others.
- procedures can be applied to arguments (i.e. use as the value
of the first subexpression in a combination)
- pairs have the operations car, cdr, etc.
- Abstract data (separate interface from implementation)
- constructors, e.g. CONS for pairs
- predicates, e.g. NUMBER?, STRING?,
PROCEDURE?, PAIR?
- selectors, e.g. CAR, CDR,
STRING-REF
- more sophisticated things, including readers, printers,
mutators
- specialized operators, e.g. + and >
for numbers.