Manifest typing
Encyclopedia
In computer science, manifest typing is when the software programmer explicitly identifies the type of each variable being declared. For example: if variable X is going to store integers then its type must be declared as integer.

In contrast, some programming languages use implicit typing (a.k.a. type inference
Type inference
Type inference refers to the automatic deduction of the type of an expression in a programming language. If some, but not all, type annotations are already present it is referred to as type reconstruction....

) where the type is deduced from context or allow for dynamic typing in which the variable is just declared and may be assigned a value of any type at runtime.

Examples

Consider the following example written in the C programming language
C (programming language)
C is a general-purpose computer programming language developed between 1969 and 1973 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating system....

:

  1. include


int main(void)
{
char s[] = "Test String";
float x = 0.0;
int y = 0;

printf("Hello World\n");
return 0;
}


Note that the variables s, x, and y were declared as a character array, floating point number, and an integer, respectively. The type system rejects, at compile-time, such fallacies as trying to add s and x.

In contrast, in Standard ML
Standard ML
Standard ML is a general-purpose, modular, functional programming language with compile-time type checking and type inference. It is popular among compiler writers and programming language researchers, as well as in the development of theorem provers.SML is a modern descendant of the ML...

, the types are not explicitly declared. Instead, the type is determined by the type of the assigned expression.

let val s = "Test String"
val x = 0.0
val y = 0
in print "Hello World\n"
end

There are no manifest types in this program, but the compiler still infers the types string, real and int for them, and would reject the expression s+x as a compile-time error.

External links

The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK