FACTOID # 29: 73.3% of America's gross operating surplus in motion picture and sound recording industries comes from California.
 
 Home   Encyclopedia   Statistics   States A-Z   Flags   Maps   FAQ   About 
   
 
WHAT'S NEW
 

SEARCH ALL

FACTS & STATISTICS    Advanced view

Search encyclopedia, statistics and forums:

 

 

(* = Graphable)

 

 


Encyclopedia > Type system

In computer science, a type system defines how a programming language classifies values and expressions into types, how it can manipulate those types and how they interact. A type identifies a value or set of values as having a particular meaning or purpose (although some types, such as abstract types and function types, might not be represented as values in the running computer program). Type systems vary significantly between languages with, perhaps, the most important variations being their compile-time syntactic and run-time operational implementations. Computer science, or computing science, is the study of the theoretical foundations of information and computation and their implementation and application in computer systems. ... A programming language is an artificial language that can be used to control the behavior of a machine, particularly a computer. ... In computer science, a value is a sequence of bits that is interpreted according to some data type. ... An expression in a programming language is a combination of values and functions or procedures, interpreted according to the particular rules of precedence and of association for a particular programming language, which computes and then returns another value. ... In programming languages a data type defines a set of values and the allowable operations on those values[1]. For example, in the Java programming language, the int type represents the set of 32-bit integers ranging in value from -2,147,483,648 to 2,147,483,647, and...


A compiler may use the static type of a value to optimize the storage it needs and the choice of algorithms for operations on the value. For example, in many C compilers the "float" data type is represented in 32 bits, in accordance with the IEEE specification for single-precision floating point numbers. Thus, C uses floating-point-specific operations on those values (floating-point addition, multiplication, etc.). A diagram of the operation of a typical multi-language, multi-target compiler. ... C is a general-purpose, block structured, procedural, imperative computer programming language developed in 1972 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating system. ... In programming languages a data type defines a set of values and the allowable operations on those values[1]. For example, in the Java programming language, the int type represents the set of 32-bit integers ranging in value from -2,147,483,648 to 2,147,483,647, and... This article is about the unit of information. ... The IEEE Standard for Binary Floating-Point Arithmetic (IEEE 754) is the most widely-used standard for floating-point computation, and is followed by many CPU and FPU implementations. ...


The depth of type constraints and the manner of their evaluation affect the typing of the language. Further, a programming language may associate an operation with varying concrete algorithms on each type in the case of type polymorphism. Type theory is the study of type systems, although the concrete type systems of programming languages originate from practical issues of computer architecture, compiler implementation, and language design. The Greek meaning of the words poly and morph together imply that a single entity can take on multiple forms. In the field of computer science, there are two fundamentally different types of polymorphism; subtype polymorphism, and parametric polymorphism. ... At the broadest level, type theory is the branch of mathematics and logic that first creates a hierarchy of types, then assigns each mathematical (and possibly other) entity to a type. ...

Contents

Basis

Assigning data types (typing) gives meaning to collections of bits. Types usually have associations either with values in memory or with objects such as variables. Because any value simply consists of a set of bits in a computer, hardware makes no distinction even between memory addresses, instruction code, characters, integers and floating-point numbers. Assignment to a type informs programs and programmers how those bit collections should be treated. This article is about the unit of information. ... The terms storage (U.K.) or memory (U.S.) refer to the parts of a digital computer that retain physical state (data) for some interval of time, possibly even after electrical power to the computer is turned off. ... In strictly mathematical branches of computer science the term object is used in a purely mathematical sense to refer to any thing. While this interpretation is useful in the discussion of abstract theory, it is not concrete enough to serve as a primitive datatype in the discussion of more concrete... In computer science and mathematics, a variable is a symbol denoting a quantity or symbolic representation. ... This article is about the machine. ... In computer science, a memory address is a unique identifier for a memory location at which a CPU or other device can store a piece of data for later retrieval. ... A computer can perform operations, each of which is assigned a numeric code called an opcode. ... Not to be confused with Natural number. ... A floating-point number is a digital representation for a number in a certain subset of the rational numbers, and is often used to approximate an arbitrary real number on a computer. ...


Major functions type systems provide include:

  • Safety - Use of types may allow a compiler to detect meaningless or probably invalid code. For example, we can identify an expression 3 / "Hello, World" as invalid because one cannot divide (in any usual sense) an integer by a string. As discussed below, strong typing offers more safety, but does not necessarily guarantee complete safety (see type-safety for more information).
  • Optimization - Static type-checking may provide useful compile-time information. For example, if a type requires a value must align in memory at a multiple of 4 bytes, the compiler may be able to use more efficient machine instructions.
  • Documentation - In more expressive type systems, types can serve as a form of documentation, since they can illustrate the intent of the programmer. For instance, timestamps may be a subtype of integers—but if a programmer declares a function as returning a timestamp type rather than merely an integer type, this documents part of the meaning of the function.
  • Abstraction (or modularity) - Types allow programmers to think about programs at a higher level than the bit or byte, not bothering with low-level implementation. For example, programmers can think of a string as a collections of characters value instead of as a mere array of bytes. Or, types can allow programmers to express the interface between two subsystems. This help localize the definitions required for interoperability of the subsystems and prevents inconsistencies when those subsystems communicate.

Notice, however, that type safety is not equivalent to program correctness. A program may give the wrong result and be safely typed, producing no compiler errors. Other methods are needed to ensure a program is correct. A diagram of the operation of a typical multi-language, multi-target compiler. ... Not to be confused with Natural number. ... In computer programming and formal language theory, (and other branches of mathematics), a string is an ordered sequence of symbols. ... In computer science, type safety is a property attributed to some, but not all, programming languages. ... In general terms, documentation is any communicable material (such as text, video, audio, etc. ... An interface defines the communication boundary between two entities, such as a piece of software, a hardware device, or a user. ... Software testing is the process used to assess the quality of computer software. ...


A program typically associates each value 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 become associated with a type. For example: In computer science, a subtype is a datatype that is generally related to another datatype (the supertype) by some notion of substitutability, meaning that computer programs written to operate on elements of the supertype can also operate on elements of the subtype. ... In strictly mathematical branches of computer science the term object is used in a purely mathematical sense to refer to any thing. While this interpretation is useful in the discussion of abstract theory, it is not concrete enough to serve as a primitive datatype in the discussion of more concrete... It has been suggested that this article or section be merged into Modularity (programming). ... In computer science, dependency or coupling is the degree to which each program module relies on each other module. ...

A type system, specified in for each programming language, controls the ways typed programs may behave, and makes behavior outside these rules illegal. An effect system typically provides more fine-grained control than does a type system. In programming languages a data type defines a set of values and the allowable operations on those values[1]. For example, in the Java programming language, the int type represents the set of 32-bit integers ranging in value from -2,147,483,648 to 2,147,483,647, and... In object-oriented programming, a class is a programming language construct used to group related fields and methods. ... Kind can mean: Hundreds Bankekind Hundred - a hundred of Ostrogothia in Sweden Frökind Hundred - a hundred of Westrogothia in Sweden Hammarkind Hundred - a hundred of Ostrogothia in Sweden Hanekind Hundred - a hundred of Ostrogothia in Sweden Kind Hundred - a hundred divided between Hallandia, Smalandia and Westrogothia in Sweden Kinda... An effect system is a formal system which describes the computational effects of computer programs, such as side effects. ...


More formally, type theory studies type systems. At the broadest level, type theory is the branch of mathematics and logic that first creates a hierarchy of types, then assigns each mathematical (and possibly other) entity to a type. ...


Type checking

The process of verifying and enforcing the constraints of types – type checking – may occur either at compile-time (a static check) or run-time (a dynamic check). If a language specification requires its typing rules strongly (ie, more or less allowing only those automatic type conversions which do not lose information), one can refer to the process as strongly typed, if not, as weakly typed. The terms are not used in a strict sense. In computer science, compile time, as opposed to runtime, is the time when a compiler compiles code written in a programming language into an executable form. ... In computer science, runtime describes the operation of a computer program, the duration of its execution, from beginning to termination (compare compile time). ...


Static typing

A programming language is said to use static typing when type checking is performed during compile-time as opposed to run-time. Examples of languages that use static typing include C, C++, C#, Java, Fortran, Pascal, and Haskell. Static typing allows many errors to be caught earlier, and so allows for program execution to be more efficient (ie, faster or taking reduced memory). Java language redirects here. ... Fortran (previously FORTRAN[1]) is a general-purpose[2], procedural,[3] imperative programming language that is especially suited to numeric computation and scientific computing. ... The pascal (symbol: Pa) is the SI unit of pressure. ... // Haskell may refer ro: Haskell (programming language), a standardized pure functional programming language with non-strict semantics Haskell Indian Nations University, a four year degree granting university in Lawrence, Kansas which offers free tuition to members of registered Native American tribes in the United States Haskell Free Library and Opera... Fail-fast is a property of a system or module with respect to its response to failures. ...


Dynamic typing

A programming language is said to use dynamic typing when type checking is performed at run-time (also known as "late-binding") as opposed to compile-time. Examples of languages that use dynamic typing include Lisp, Perl, Python, and Smalltalk. Compared to static typing (or 'early-binding'), dynamic typing is more flexible because of theoretical limitations on the decidability of certain static program analysis problems; these prevent the same level of flexibility from being achieved with static typing[citation needed]. There is also less code to write for a given functionality, but dynamic typing is slower at execution time as type checking, done then, takes time. However in practice, for many types of problem, these speed differences may not be significant or noticeable. “LISP” redirects here. ... For other uses, see Perl (disambiguation). ... Python is a general-purpose, high-level programming language. ... For other uses, see Small talk. ...


When used by itself, dynamic typing relies much more on testing for the discovery of errors. If code is not executed then only interpreter checks for syntax may be done, as opposed to the additional type checks done in a statically typed language. These static type checks are necessarily simpler than those which can be applied at run time, since less information is available to the language system then. Infrequently executed code such as error handlers, may take more effort to test in a dynamic typing context, but equally, there is no illusion that parts of a dynamic program are fit for purpose without them being tested as opposed to being merely type-checked.


Combinations of dynamic and static typing

Some statically typed languages have a "back door" in the language specification that enables programmers to write code that does not statically type check. For example, Java and most C-style languages have "casting"; such operations may be unsafe at runtime, in that they can cause unwanted behavior due to incorrect typing of values when the program runs. In computer science, type conversion or typecasting refers to changing an entity of one data type into another. ...


The presence of static typing in a programming language does not necessarily imply the absence of all dynamic typing mechanisms. For example, Java uses static typing, but certain operations require the support of runtime type tests, a form of dynamic typing. See programming language for more discussion of the interactions between static and dynamic typing. A programming language is an artificial language that can be used to control the behavior of a machine, particularly a computer. ...


Static and dynamic type checking in practice

The choice between static and dynamic typing requires trade-offs. A Tradeoff usually refers to losing one quality or aspect of something in return for gaining another quality or aspect. ...


Static typing can find type errors reliably at compile time. This should increase the reliability of the delivered program. However, programmers disagree over how commonly type errors occur, and thus what proportion of those bugs which are written would be caught by static typing. Static typing advocates believe programs are more reliable when they have been well type-checked, while dynamic typing advocates point to distributed code that has proven reliable and to small bug databases. The value of static typing, then, presumably increases as the strength of the type system is increased. Advocates of strongly typed languages such as ML and Haskell have suggested that almost all bugs can be considered type errors, if the types used in a program are properly declared by the programmer or correctly inferred by the compiler.[1] ML is a general-purpose functional programming language developed by Robin Milner and others in the late 1970s at the University of Edinburgh, whose syntax is inspired by ISWIM. Historically, ML stands for metalanguage as it was conceived to develop proof tactics in the LCF theorem prover (the language of... Haskell is a standardized purely functional programming language with non-strict semantics, named after the logician Haskell Curry. ...


Static typing usually results in compiled code that executes more quickly. When the compiler knows the exact data types that are in use, it can produce optimized machine code. Further, compilers for statically typed languages can find assembler shortcuts more easily. Some dynamically-typed languages such as Common Lisp allow optional type declarations for optimization for this very reason. Static typing makes this pervasive. See optimization. Common Lisp, commonly abbreviated CL, is a dialect of the Lisp programming language, published in ANSI standard X3. ... In computing, optimization is the process of modifying a system to make some aspect of it work more efficiently or use fewer resources. ...


By contrast, dynamic typing may allow compilers and interpreters to run more quickly, since changes to source code in dynamically-typed languages may result in less checking to perform and less code to revisit. This too may reduce the edit-compile-test-debug cycle.


Statically-typed languages which lack type inference (such as Java) require that programmers declare the types they intend a method or function to use. This can serve as additional documentation for the program, which the compiler will not permit the programmer to ignore or permit to drift out of synchronization. However, a language can be statically typed without requiring type declarations (examples include Scala and C#3.0), so this is not a necessary consequence of static typing. Type inference is a feature present in some strongly statically typed programming languages. ... Scala is a multi-paradigm programming language designed to express common programming patterns in a concise, elegant, and type-safe way. ...


Dynamic typing allows constructs that some static type checking would reject as illegal. For example, eval functions, which execute arbitrary data as code, become possible (however, the typing within that evaluated code might remain static). Furthermore, dynamic typing accommodates transitional code and prototyping, such as allowing a string to be used in place of a data structure. Recent enhancements to statically typed languages (e.g. Haskell Generalized algebraic data types) have allowed eval functions to be written in a type-safe way. In some programming languages, eval is a function which evaluates a string as though it were an expression and returns a result; in others, it executes multiple lines of code as though they had been included instead of the line including the eval. ... This article or section is in need of attention from an expert on the subject. ...


Dynamic typing typically makes metaprogramming more effective and easier to use. For example, C++ templates are typically more cumbersome to write than the equivalent Ruby or Python code.[citation needed] More advanced run-time constructs such as metaclasses and introspection are often more difficult to use in statically-typed languages. Metaprogramming is the writing of computer programs that write or manipulate other programs (or themselves) as their data or that do part of the work during compile time that is otherwise done at run time. ... C++ (pronounced ) is a general-purpose programming language. ... [[Im[[Image:Example. ... Ruby is a reflective, object-oriented programming language. ... Python is a general-purpose, high-level programming language. ... In object-oriented programming, a metaclass is a class whose instances are classes. ... In computing, type introspection is a capability of some object-oriented programming languages to determine the type of an object at runtime. ...


Strong and weak typing

Main article: strongly-typed programming language

One definition of strongly typed involves preventing success for an operation on arguments which have the wrong type. A C cast gone wrong exemplifies the problem of absent strong typing; if a programmer casts a value from one type to another in C, not only must the compiler allow the code at compile time, but the runtime must allow it as well. This may permit more compact and faster C code, but it can make debugging more difficult. In computer science and computer programming, the term strong typing is used to describe those situations where programming languages specify one or more restrictions on how operations involving values having different datatypes can be intermixed. ... C is a general-purpose, block structured, procedural, imperative computer programming language developed in 1972 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating system. ... In computer science, type conversion or typecasting refers to changing an entity of one data type into another. ... Debugging is a methodical process of finding and reducing the number of bugs, or defects, in a computer program or a piece of electronic hardware thus making it behave as expected. ...


Some observers use the term memory-safe language (or just safe language) to describe languages that do not allow undefined operations to occur. For example, a memory-safe language will check array bounds, or else statically guarantee (i.e., at compile time before execution) that array accesses out of the array boundaries will cause compile-time and perhaps runtime errors. In computer programming, bounds checking is the name given to any method of detecting whether or not an index given lies within the limits of an array. ...


Weak typing means that a language implicitly converts (or casts) types when used. Revisiting the previous example, we have:

 var x := 5; // (1) (two integers) var y := "37"; // (2) (a string and an integer) x + y; // (3) (?) 

It is not clear what result one would get in a weakly typed language. Some languages, such as Visual Basic, would produce runnable code producing the result 42: the system would convert the string "37" into the number 37 to forcibly make sense of the operation. Other languages like JavaScript would produce the result "537": the system would convert the number 5 to the string "5" and then concatenate the two. In both Visual Basic and JavaScript, the resulting type is determined by rules that take both operands into consideration. In some languages, such as AppleScript, the type of the resulting value is determined by the type of the left-most operand only. This article is about the Visual Basic language shipping with Microsoft Visual Studio 6. ... JavaScript is a scripting language most often used for client-side web development. ... In mathematics, an operand is one of the inputs of an operator. ... AppleScript is a scripting language devised by Apple, Inc. ...


Careful language design has also allowed languages to appear weakly-typed (through type inference and other techniques) for usability while preserving the type checking and protection offered by strongly-typed languages. Examples include VB.Net, C#, and Java. Type inference is a feature present in some strongly statically typed programming languages. ... Visual Basic . ... The title given to this article is incorrect due to technical limitations. ... Java language redirects here. ...


Reduction of operator overloading, such as not using "+" for string concatenation in addition to arithmetic addition, can reduce some of the confusion caused by weak typing.[citation needed] For example, PHP uses periods (.) for string concatenation, and similarly Ada uses the ampersand (&). In computer programming, operator overloading (less commonly known as operator ad-hoc polymorphism) is a specific case of polymorphism in which some or all of operators like +, = or == have different implementations depending on the types of their arguments. ... For other uses, see PHP (disambiguation). ... Ada is a structured, statically typed, imperative, and object-oriented high-level computer programming language. ...


Safely and unsafely typed systems

Main article: Type safety

A third way of categorizing the type system of a programming language uses the safety of typed operations and conversions. Computer scientists consider a language "type-safe" if it does not allow operations or conversions which lead to erroneous conditions. In computer science, a programming language is type safe when the language does not permit the programmer to treat a value as a type to which it does not belong. ...


Let us again have a look at the pseudocode example:

 var x := 5; // (1) var y := "37"; // (2) var z := x + y; // (3) 

In languages like Visual Basic variable z in the example acquires the value 42. While the programmer may or may not have intended this, the language defines the result specifically, and the program does not crash or assign an ill-defined value to z. In this respect, such languages are type-safe. Visual Basic (VB) is an event driven programming language and associated development environment, created by Microsoft. ...


Now let us look at the same example in C:

 int x = 5; char y[] = "37"; char* z = x + y; 

In this example z will point to a memory address five characters beyond y, equivalent to two characters after the terminating zero character of the string pointed to by y. The content of that location is undefined, and might lie outside addressable memory. The mere computation of such a pointer may result in undefined behavior (including the program crashing) according to C standards, and in typical systems dereferencing z at this point could cause the program to crash. We have a well-typed, but not memory-safe program — a condition that cannot occur in a type-safe language. This article discusses a general notion of reference in computing. ...


Polymorphism and types

The term "polymorphism" refers to the ability of code (in particular, methods or classes) to act on values of multiple types, or to the ability of different instances of the same data-structure to contain elements of different types. Type systems that allow polymorphism generally do so in order to improve the potential for code re-use: in a language with polymorphism, programmers need only implement a data structure such as a list or an associative array once, rather than once for each type of element with which they plan to use it. For this reason computer scientists sometimes call the use of certain forms of polymorphism generic programming. The type-theoretic foundations of polymorphism are closely related to those of abstraction, modularity and (in some cases) subtyping. In computer science, polymorphism means allowing a single definition to be used with different types of data (specifically, different classes of objects). ... An associative array (also map, hash, dictionary, finite map, lookup table, and in query-processing an index or index file) is an abstract data type composed of a collection of keys and a collection of values, where each key is associated with one value. ... Generic programming is a style of computer programming where algorithms are written in an extended grammar and are made adaptable by specifying variable parts that are then somehow instantiated later by the compiler with respect to the base grammar. ... In computer science, abstraction is a mechanism and practice to reduce and factor out details so that one can focus on a few concepts at a time. ... It has been suggested that this article or section be merged into Modularity (programming). ... In computer science, a subtype is a datatype that is generally related to another datatype (the supertype) by some notion of substitutability, meaning that computer programs written to operate on elements of the supertype can also operate on elements of the subtype. ...


Duck typing

Main article: Duck typing

In "duck typing," a statement calling a method on an object does not rely on the type of the object; only that the object, of whatever type, must implement the method called. Duck typing is a dynamically-typed, object-oriented manifestation of structural type systems, as opposed to a nominative type systems. In computer programming, duck typing is a style of dynamic typing in which an objects current set of methods and properties determines the valid semantics, rather than its inheritance from a particular class. ... A structual type system is a major class of type system, in which type compatibility and equivalence are determined by the types structure, and not through explicit declarations. ... A nominative type system is a major classes of type system, in which type compatibility and equivalence is determined by explicit declarations and/or the name of the types. ...


Initially coined by Alex Martelli in the Python community, duck typing uses the premise that (referring to a value) "if it walks like a duck, and quacks like a duck, then it is a duck". Alex Martelli is a member of the Python Software Foundation and works, as of 2006, as Ãœber Tech Lead for Google, Inc. ... Python is a general-purpose, high-level programming language. ...


Specialized type systems

Many type systems have been created that are specialized for use in certain environments, with certain types of data, or for out-of-band static program analysis. Frequently these are based on ideas from formal type theory and are only available as part of prototype research systems. At the broadest level, type theory is the branch of mathematics and logic that first creates a hierarchy of types, then assigns each mathematical (and possibly other) entity to a type. ...


Dependent types

Dependent types are based on the idea of using scalars or values to more precisely describe the type of some other value. For example, "matrix(3,3)" might be the type of a 3×3 matrix. We can then define typing rules such as the following rule for matrix multiplication: In computer science and logic, a dependent type is a type which depends on a value. ...

matrix_multiply : matrix(k,m) × matrix(m,n) → matrix(k,n)

where k, m, n are arbitrary positive integer values. A variant of ML called Dependent ML has been created based on this type system, but because type-checking conventional dependent types is undecidable, not all programs using them can be type-checked without some kind of limitations. Dependent ML limits the sort of equality it can decide to Presburger arithmetic; other languages such as Epigram make the value of all expressions in the language decidable so that type checking can be decidable. ML is a general-purpose functional programming language developed by Robin Milner and others in the late 1970s at the University of Edinburgh, whose syntax is inspired by ISWIM. Historically, ML stands for metalanguage as it was conceived to develop proof tactics in the LCF theorem prover (the language of... Dependent ML is an experimental functional programming language proposed by Frank Pfenning and Hongwei Xi. ... In computability theory a countable set is called recursive, computable or decidable if we can construct an algorithm which terminates after a finite amount of time and decides whether a given element belongs to the set or not. ... Presburger arithmetic is the first-order theory of the natural numbers with addition. ... monogram is the name of a functional programming language with dependent types and of the IDE usually packaged with it. ...


Linear types

Linear types, based on the theory of linear logic, and closely related to uniqueness types, are types assigned to values having the property that they have one and only one reference to them at all times. These are valuable for describing large immutable values such as strings, files, and so on, because any operation that simultaneously destroys a linear object and creates a similar object (such as 'str = str + "a"') can be optimized "under the hood" into an in-place mutation. Normally this is not possible because such mutations could cause side effects on parts of the program holding other references to the object, violating referential transparency. They are also used in the prototype operating system Singularity for interprocess communication, statically ensuring that processes cannot share objects in shared memory in order to prevent race conditions. The Clean language (a Haskell-like language) uses this type system in order to gain a lot of speed while remaining safe. In mathematical logic, linear logic is a type of substructural logic that denies the structural rules of weakening and contraction. ... In computing, a unique type guarantees that an object is used in a single-threaded way, without duplicating references to it. ... In object-oriented and functional programming, an immutable object is an object whose state cannot be modified after it is created. ... Referential transparency is a property of parts of computer programs. ... In computer science, Clean is a general-purpose purely functional computer programming language. ... Haskell is a standardized purely functional programming language with non-strict semantics, named after the logician Haskell Curry. ...


Intersection types

Intersection types are types describing values that belong to both of two other given types with overlapping value sets. For example, in C the signed char has range -128 to 127 and the unsigned char has range 0 to 255, so the intersection type of these two types would have range 0 to 127. Such an intersection type could be safely passed into functions expecting either signed or unsigned chars, because it is compatible with both types.


Intersection types are useful for describing overloaded function types: For example, if "int → int" is the type of functions taking an integer argument and returning an integer, and "float → float" is the type of functions taking a float argument and returning a float, then the intersection of these two types can be used to describe functions that do one or the other, based on what type of input they are given. Such a function could be passed into another function expecting an "int → int" function safely; it simply would not use the "float → float" functionality.


In a subclassing hierarchy, the intersection of a type and an ancestor type (such as its parent) is the most derived type. The intersection of sibling types is empty.


The Forsythe language includes a general implementation of intersection types. A restricted form is refinement types.


Union types

Union types are types describing values that belong to either of two types. For example, in C, the signed char has range -128 to 127, and the unsigned char has range 0 to 255, so the union of these two types would have range -128 to 255. Any function handling this union type would have to deal with integers in this complete range. More generally, the only valid operations on a union type are operations that are valid on both types being unioned. C's "union" concept is similar to union types, but is not typesafe because it permits operations that are valid on either type, rather than both. Union types are important in program analysis, where they are used to represent symbolic values whose exact nature (eg, value or type) is not known. In computer science, a union is a data structure that stores one of several types of data at a single location. ...


In a subclassing hierarchy, the union of a type and an ancestor type (such as its parent) is the ancestor type. The union of sibling types is a subtype of their common ancestor (that is, all operations permitted on their common ancestor are permitted on the union type, but they may also have other valid operations in common).


Existential types

Existential types are frequently used to represent modules and abstract data types because of their ability to separate implementation from interface. For example, in C pseudocode, the type "T = ∃X { X a; int f(X); }" describes a module interface that has a data member of type X and a function that takes a parameter of the same type X and returns an integer. This could be implemented in different ways; for example: Look up module in Wiktionary, the free dictionary. ... In computing, an abstract data type (ADT) is a specification of a set of data and the set of operations that can be performed on the data. ...

  • intT { int a; int f(int); }
  • floatT { float a; int f(float); }

These types are both subtypes of the more general existential type T and correspond to concrete implementation types, so any value of one of these types is a value of type T. Given a value "t" of type "T", we know that "t.f(t.a)" is well-typed, regardless of what the abstract type X is. This gives flexibility for choosing types suited to a particular implementation while clients that use only values of the interface type — the existential type — are isolated from these choices.


Explicit or implicit declaration and inference

For more details on this topic, see Type inference.

Many static type systems, such as C's and Java's, require type declarations: The programmer must explicitly associate each variable with a particular type. Others, such as Haskell's, perform type inference: The compiler draws conclusions about the types of variables based on how programmers use those variables. For example, given a function f(x,y) which adds x and y together, the compiler can infer that x and y must be numbers – since addition is only defined for numbers. Therefore, any call to f elsewhere in the program that specifies a non-numeric type (such as a string or list) as an argument would signal an error. Type inference is a feature present in some strongly statically typed programming languages. ... Type inference is a feature present in some strongly statically typed programming languages. ...


Numerical and string constants and expressions in code can and often do imply type in a particular context. For example, an expression 3.14 might imply a type of floating-point, while [1, 2, 3] might imply a list of integers – typically an array. This article or section is in need of attention from an expert on the subject. ... For the microarray in genetics, see SNP array. ...


Type inference is only possible if it is decidable in the type theory in question. Haskell's type system, a version of Hindley-Milner, is a restriction of System Fω to so-called rank-1 polymorphic types, in which type inference is decidable. Most Haskell compilers allow arbitrary-rank polymorphism as an extension, but this makes type inference undecidable. (Type checking is decidable, however, and rank-1 programs still have type inference; higher rank polymorphic programs are rejected unless given explicit type annotations.) The word decidable has formal meaning in computability theory, the theory of formal languages, and mathematical logic. ... Type inference is a feature present in some strongly statically typed programming languages. ... System F is a typed lambda calculus. ...


Types of types

A type of types is a kind. Kinds appear explicitly in typeful programming, such as a type constructor in the Haskell programming language. In computer science typeful programming is a programming style identified by widespread use of type information handled through mechanical typechecking techniques. ... Haskell is a standardized purely functional programming language with non-strict semantics, named after the logician Haskell Curry. ...


Types fall into several broad categories:

In computer science, primitive types — as distinct from composite types — are data types provided by a programming language as basic building blocks. ... Not to be confused with Natural number. ... A floating-point number is a digital representation for a number in a certain subset of the rational numbers, and is often used to approximate an arbitrary real number on a computer. ... For use in mathematics, see Boolean algebra (structure). ... In computer science, a variable has integral type if the variable represents an integer. ... A floating-point number is a digital representation for a number in a certain subset of the rational numbers, and is often used to approximate an arbitrary real number on a computer. ... This article or section is in need of attention from an expert on the subject. ... In the C++ programming language, a reference is a simple reference datatype that is less powerful but safer than the pointer type inherited from C, which is a reference in the general sense but not in the sense used by C++. // The declaration of the form <Type> & <Name>... where <Type... In computer science, composite types are datatypes which can be constructed in a programming language out of that languages primitive types and other composite types. ... For the microarray in genetics, see SNP array. ... This article is about the data structure. ... In computing, an abstract data type (ADT) is a specification of a set of data and the set of operations that can be performed on the data. ... In computer science, a subtype is a datatype that is generally related to another datatype (the supertype) by some notion of substitutability, meaning that computer programs written to operate on elements of the supertype can also operate on elements of the subtype. ... A derived type is a type given a new type but structurally the same as the original type. ... In computer science, an object type (a. ... In computer science and mathematics, a variable is a symbol denoting a quantity or symbolic representation. ... In computing, a partial type is a data type definition which spans multiple source code files. ... In computer programming languages, a recursive type is a data type for values that may contain other values of the same type. ... A function object, often called a functor, is a computer programming construct allowing an object to be invoked or called as if it were an ordinary function, usually with the same syntax. ... In predicate logic, universal quantification is an attempt to formalize the notion that something (a logical predicate) is true for everything, or every relevant thing. ... In predicate logic, an existential quantification is the predication of a property or relation to at least one member of the domain. ... It has been suggested that this article or section be merged into Modularity (programming). ... In computer science and logic, a dependent type is a type which depends on a value. ...

Compatibility: equivalence and subtyping

A type-checker for a statically typed language must verify that the type of any expression is consistent with the type expected by the context in which that expression appears. For instance, in an assignment statement of the form x := e, the inferred type of the expression e must be consistent with the declared or inferred type of the variable x. This notion of consistency, called compatibility, is specific to each programming language. An expression in a programming language is a combination of values and functions or procedures, interpreted according to the particular rules of precedence and of association for a particular programming language, which computes and then returns another value. ... Assignment statement is a statement where a destination is assigned a specific value , mostly copied from a source , where the source can be either a variable , a constant or any other . ...


If the type of e and the type of x are the same and assignment is allowed for that type, then this is a valid expression. In the simplest type systems, therefore, the question of whether two types are compatible reduces to that of whether they are equal (or equivalent). Different languages, however, have different criteria for when two type expressions are understood to denote the same type. These different equational theories of types vary widely, two extreme cases being structural type systems, in which any two types are equivalent that describe values with the same structure, and nominative type systems, in which no two syntactically distinct type expressions denote the same type (i.e., types must have the same "name" in order to be equal). A structual type system is a major class of type system, in which type compatibility and equivalence are determined by the types structure, and not through explicit declarations. ... A nominative type system is a major classes of type system, in which type compatibility and equivalence is determined by explicit declarations and/or the name of the types. ...


In languages with subtyping, the compatibility relation is more complex. In particular, if A is a subtype of B, then a value of type A can be used in a context where one of type B is expected, even if the reverse is not true. Like equivalence, the subtype relation is defined differently for each programming language, with many variations possible. The presence of parametric or ad hoc polymorphism in a language may also have implications for type compatibility. In computer science, a subtype is a datatype that is generally related to another datatype (the supertype) by some notion of substitutability, meaning that computer programs written to operate on elements of the supertype can also operate on elements of the subtype. ... In computer science, polymorphism means allowing a single definition to be used with different types of data (specifically, different classes of objects). ...


Controversy

There are often conflicts between those who prefer strong and/or statically-typed languages and those who prefer dynamic or free-form typing. The first group advocates for the early detection of errors during compilation and increased runtime performance, while the latter group advocates for rapid prototyping that is possible with a more dynamic typing system and that type errors are only a small subset of errors in a program.[2][3]. Related to this is the consideration that often there is no need to manually declare types in a programming language with type inference; thus, the overhead is automatically lowered for some languages.


References

  1. ^ Dependent Types in Practical Programming - Xi, Pfenning (ResearchIndex)
  2. ^ Meijer, Erik and Peter Drayton. Static Typing Where Possible, Dynamic Typing When Needed: The End of the Cold War Between Programming Languages. Microsoft Corporation.
  3. ^ Bruce Eckel. Strong Typing vs. Strong Testing. mindview.

Microsoft Corporation, (NASDAQ: MSFT, HKSE: 4338) is a multinational computer technology corporation with global annual revenue of US$44. ...

See also

Wikibooks
Wikibooks Ada Programming has a page on the topic of
Types
Wikibooks
Wikibooks Haskell has a page on the topic of
Class Declarations

Image File history File links Wikibooks-logo-en. ... Wikibooks logo Wikibooks, previously called Wikimedia Free Textbook Project and Wikimedia-Textbooks, is a wiki for the creation of books. ... Image File history File links Wikibooks-logo-en. ... Wikibooks logo Wikibooks, previously called Wikimedia Free Textbook Project and Wikimedia-Textbooks, is a wiki for the creation of books. ... In computer programming, operator overloading (less commonly known as operator ad-hoc polymorphism) is a specific case of polymorphism in which some or all of operators like +, = or == have different implementations depending on the types of their arguments. ... In simple terms, polymorphism lets you treat derived class members just like their parent class members. ... A programming language is an artificial language that can be used to control the behavior of a machine, particularly a computer. ... A type signature defines the inputs and outputs for a function or method. ... Signedness is a property of an integer number used by a compiler to indicate if variables of a numeric type are capable of storing both positive and negative numbers, or just positive. ...

External links


  Results from FactBites:
 
MovableType.org - Home for the MT Community (317 words)
Wow, that is a lot of people trying Movable Type out, and because MT supports multiple environments and multiple databases like MySQL, Postgres, SQLite, Microsoft SQLServer and Oracle, that is a lot of different ways in which Movable Type can be configured once it has left our showroom floor.
Search Results for movable type: Movable Type 4.2 RC is here, fast!
TTFpj TrueTypeFonts 1.0 for Movable Type, by SpagDesign
Type of Economic System (305 words)
Type of economic system used countries over the world differ from country to country.
Mixed Economy is such a type of economic system, where both capitalist economic norms as well as socialist economic norms exist.
Socialist Economy is a type of economic system where the means of production and distribution are made by the public authority or the Government.
  More results at FactBites »

 
 

COMMENTARY     


Share your thoughts, questions and commentary here
Your name
Your comments

Want to know more?
Search encyclopedia, statistics and forums:

 


Press Releases |  Feeds | Contact
The Wikipedia article included on this page is licensed under the GFDL.
Images may be subject to relevant owners' copyright.
All other elements are (c) copyright NationMaster.com 2003-5. All Rights Reserved.
Usage implies agreement with terms, 1022, m