In a programming language context, types are used to distinguish values that have different properties. The main reason for using types is to avoid errors: If a value is used in a context where it is expected to have a certain property, and it does not have that property, this is an error. Conceptually, it is an error even if it does not lead to an error message: It is an error in the logic of the program, just like adding apples and oranges and expecting bananas is a logical error.

错误:搜索内容不能为空,请输入英文关键词
错误:关键词超出字数限制,请精简
高级检索

Types

  • Torben Ægidius Mogensen

摘要

In a programming language context, types are used to distinguish values that have different properties. The main reason for using types is to avoid errors: If a value is used in a context where it is expected to have a certain property, and it does not have that property, this is an error. Conceptually, it is an error even if it does not lead to an error message: It is an error in the logic of the program, just like adding apples and oranges and expecting bananas is a logical error.