Type

A type is a set of values supporting a certain set of operations.

Related concepts:  ValueClass

Closest Wikipedia entry:  Type system — In programming languages, a type system is a logical system comprising a set of rules that assigns a property called a type to the various constructs of a computer program, such as variables, expressions, functions or modules. These types formalize and enforce the otherwise implicit categories the programmer uses for algebraic data types, data structures, or other components (e.g. "string", "array of float", "function returning boolean"). The main purpose of a type system is to reduce possibilities for bugs in computer programs by defining interfaces between different parts of a computer program, and then checking that the parts have been connected in a consistent way.

Authoritative Definition

Wikipedia does not necessarily offer the best fitting definition of a concept. The exact meaning we attribute to the concept of Type is based on principled authoritative sources such as:

Misconceptions about Type
36 documented Misconceptions

Check Yourself
Misconception
ArrayElementTypeRepeats
The type of a multi-dimensional array is written as T[] T[] T[]
Misconception
ArrayElementsUntyped
Elements of arrays are untyped
Misconception
ArrayLengthPartOfType
The length of an array is part of its type
Misconception
ArrayRankNotPartOfType
The rank of an array is not part of its type
Misconception
CharNotNumeric
Char is not a numeric type
Misconception
CompositeExpressionsUntyped
Expressions that consist of multiple parts have no type
Misconception
ExpressionsDynamicallyTyped
One has to evaluate an expression to determine its type
Misconception
IntegerDivisionToRational
Dividing two integers can produce a rational number
Misconception
LargeIntegerLong
Large integer numbers have type long
Misconception
MethodWithoutReturnType
A method declaration does not need to include a return type
Misconception
NamedTypeParameter
To instantiate a generic type, one needs to specify type parameter names as well as types
Misconception
NoCastIfSameSize
If a variable is at least as big (bit-width) as a value, then no cast is needed to a assign the value to the variable
Misconception
NoFloatLiterals
There are no float literals
Misconception
NoImplicitWidening
Smaller types are never automatically converted into bigger ones without an explicit cast
Misconception
NoLongLiterals
There are no long literals
Misconception
NumericToBooleanCoercion
Numeric types can be coerced to boolean
Misconception
PrimitiveTypeParameter
Type parameters of generic types can be assigned primitive types
Misconception
PrimitiveVariablesDynamicallyTyped
The type of a primitive variable depends on its value
Misconception
RecursiveMethodImpliesRecursiveType
A class with a recursive method represents part of a recursive data structure
Misconception
ReferenceLabeledWithDynamicType
In stack and heap diagrams, reference variables are labeled with the types of the objects they refer to
Misconception
ReferenceToBooleanCoercion
Every reference type can be coerced to boolean
Misconception
ReferenceToIntegerConversion
One can cast between references and ints
Misconception
StaticCallPolymorphic
A static method call is dispatched polymorphically at runtime based on the argument types
Misconception
SubtypeCompatibleWithSupertype
A variable of a subtype can reference an object of a supertype
Misconception
SupertypeIncompatibleWithSubtype
A variable of a supertype cannot reference an object of a subtype
Misconception
TargetTyping
The type of a numerical expression depends on the type expected by the surrounding context
Misconception
UntypedVariables
Variable declarations don't need a type
Misconception
UseOfSelfTypeImpliesRecursiveType
If a class has a method that has a local variable, parameter, or return value with the class as its type, the class is a recursive type
Misconception
VoidMethodNotRecursive
A method with void return type can't be recursive
Misconception
VoidMethodReturnsValue
A method with void return type can return a value

Stay up-to-date

Follow us on  twitter to hear about new misconceptions.