| • Science | • People | • Locations | • Timeline |
| Contents | ||
The basic idea of typing is to give some semantic meaning to what is ultimately just mere bits. Types are usually associated either with values in memory or with objects such as variables. Because any value is simply a set of bits for computers, there is no distinction in hardware even among memory addresses, instruction code, characters, integers and floating-point numbers. Types tell you how you should treat those mere bits.
Major functions that type systems provide are:
"Hello, Wikipedia" / 3 is invalid because a string literal cannot be divided by an integer in the usual sense. As discussed below, strong typing offers more safety, but it does not necessarily guarantee complete safety (see type-safety for more information).
Typically each value is associated with one particular type although a type may have more than one subtype. Other entities, such as objects, modules, communication channels, dependencies, or even types themselves can be associated with a type. For example, a datatype is a type of a value, a classIn object-oriented programming, a class consists of encapsulated instance variables and subprograms, the methods mentioned below. A Class describes the rules by which objects behave; these objects are referred to as " instances" of that class. A class spe is a type of an object and a kind is a type of a type.
A type system, specified in each programming language, stipulates the ways typed programs are allowed to behave and makes behavior outside these rules illegal. An effect systemAn effect system is a formal system which describes the computational effects of computer programs, such as side effects. An effect system can be used to provide a compile-time checking of the possible effects of the program. An effect system is typically is typically more fine-grained than a type system.
More formally, the study of type systems is known as type theoryMathematical logic At the broadest level, type theory is the branch of mathematics and logic that concerns itself with classifying entities into sets called types''. In this sense, it is related to the metaphysical notion of 'type'. Modern type theory was, with the aid of lambda calculusThe lambda calculus is a formal system designed to investigate function definition, function application, and recursion. It was introduced by Alonzo Church and Stephen Cole Kleene in the 1930s; Church used the lambda calculus in 1936 to give a negative an.