In computer science, manifest typing is explicit identification by the
software programmer
A computer programmer, sometimes referred to as a software developer, a software engineer, a programmer or a coder, is a person who creates computer programs — often for larger computer software.
A programmer is someone who writes/creates ...
of 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. The term "manifest typing" is often used with the term
latent typing
In computer programming, latent typing refers to a type system where types are associated with values and not variables. An example latently typed language is Scheme A scheme is a systematic plan for the implementation of a certain idea.
Schem ...
to describe the difference between the
static
Static may refer to:
Places
*Static Nunatak, a nunatak in Antarctica
United States
* Static, Kentucky and Tennessee
*Static Peak, a mountain in Wyoming
**Static Peak Divide, a mountain pass near the peak
Science and technology Physics
*Static el ...
,
compile-time
In computer science, compile time (or compile-time) describes the time window during which a computer program is compiled.
The term is used as an adjective to describe concepts related to the context of program compilation, as opposed to concept ...
type membership of the object and its
run-time type identity.
In contrast, some programming languages use ''implicit typing'' (a.k.a.
type inference
Type inference refers to the automatic detection of the type of an expression in a formal language. These include programming languages and mathematical type systems, but also natural languages in some branches of computer science and linguistic ...
) where the type is deduced from context at compile-time or allow for
dynamic typing
In computer programming, a type system is a logical system comprising a set of rules that assigns a property called a type to every "term" (a word, phrase, or other set of symbols). Usually the terms are various constructs of a computer progra ...
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
''The C Programming Language'' (sometimes termed ''K&R'', after its authors' initials) is a computer programming book written by Brian Kernighan and Dennis Ritchie, the latter of whom originally designed and implemented the language, as well a ...
:
#include
int main(void)
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 (SML) 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 ...
, the ''types'' do not need to be 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
Manifest typing
Type systems
{{compu-lang-stub