Difference between revisions of "Type system"

From Wiki @ Karl Jones dot com
Jump to: navigation, search
(Created page with "In programming languages, a '''type system''' is a collection of rules that assign a property called type to various constructs a computer program...")
 
(See also)
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
In [[Programming language|programming languages]], a '''type system''' is a collection of rules that assign a property called type to various constructs a [[computer program]] consists of, such as [[Variable (computer science)|variables]], [[Expression (computer science)|expressions]], [[Function (programming)|functions]], or [[Modular programming|modules]].
+
In [[Programming language|programming languages]], a '''type system''' is a collection of rules that assign a property called '''type''' to various constructs a [[computer program]] consists of, such as [[Variable (computer science)|variables]], [[Expression (computer science)|expressions]], [[Function (programming)|functions]], or [[Modular programming|modules]].
  
 
== Description ==
 
== Description ==
Line 19: Line 19:
 
* [[Data type]]
 
* [[Data type]]
 
* [[Modular programming]]
 
* [[Modular programming]]
* [[Polymorphism in object-oriented programming]]
+
* [[Polymorphism (computer science)]]
 
* [[Type rules]]
 
* [[Type rules]]
 
* [[Type signature]]
 
* [[Type signature]]

Latest revision as of 07:16, 20 September 2016

In programming languages, a type system is a collection of rules that assign a property called type to various constructs a computer program consists of, such as variables, expressions, functions, or modules.

Description

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.

This checking can happen statically (at compile time), dynamically (at run time), or as a combination of static and dynamic checking.

Type systems have other purposes as well, such as enabling certain compiler optimizations, allowing for multiple dispatch, providing a form of documentation, etc.

A type system associates a type with each computed value and, by examining the flow of these values, attempts to ensure or prove that no type errors can occur. The particular type system in question determines exactly what constitutes a type error, but in general the aim is to prevent operations expecting a certain kind of value from being used with values for which that operation does not make sense (logic errors); memory errors will also be prevented.

Type systems are often specified as part of programming languages, and built into the interpreters and compilers for them; although the type system of a language can be extended by optional tools that perform additional kinds of checks using the language's original type syntax and grammar.

See also

External links