请输入您要查询的百科知识:

 

词条 Manifest typing
释义

  1. Examples

  2. References

  3. External links

{{no footnotes|date=February 2013}}{{Type systems}}

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.

Examples

Consider the following example written in the C programming language:

  1. include

int main(void) {

    char s[] = "Test String";    float x = 0.0;    int y = 0;
    printf("Hello World\");    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, 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\"  '''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
{{DEFAULTSORT:Manifest Typing}}{{compu-lang-stub}}

1 : Type systems

随便看

 

开放百科全书收录14589846条英语、德语、日语等多语种百科知识,基本涵盖了大多数领域的百科知识,是一部内容自由、开放的电子版国际百科全书。

 

Copyright © 2023 OENC.NET All Rights Reserved
京ICP备2021023879号 更新时间:2024/9/20 7:49:56