In computer science, manifest typing is explicit identification by the
software programmer 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 to describe the difference between the
static,
compile-time type membership of the object and its
run-time type identity.
In contrast, some programming languages use ''implicit typing'' (a.k.a.
type inference) where the type is deduced from context at compile-time or allow for
dynamic typing in which the variable is just declared and may be assigned a value of any type at runtime.
It's important to know the difference between manifest/implicit typing and static/dynamic typing. The first one describes how the variables (and it's types) are defined, while the second describes whether the language checks the types at compile or execution time.
Examples
Consider the following example written in the
C programming language:
#include
int main(void)
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''. Since
C23, type inference can be used in C with the keyword
auto
.
Using that feature, the preceding example could become:
#include
int main(void)
Similarly to the second example, in
Standard ML
Standard ML (SML) is a General-purpose programming language, general-purpose, High-level programming language, high-level, Modular programming, modular, Functional programming, functional programming language with compile-time type checking and t ...
, 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.
References
External links
Manifest typing
Type systems
{{compu-lang-stub