类型检查-类型系统

赋值规则检查;

基础运算规则+;

方法调用权限;

类型一致性检查、类型行为检查;

类型系统是对类型表达式合规性的检查;

Type systems are generally formulated as collections of rules for checking the “con- sistency” of programs. 

https://www.cnblogs.com/feng9exe/p/9708390.html

This section deals with more theoretical aspects of types.

type system is a set of rules used by a language to structure and organize its collection of types.

We use the term object (or data object) to denote both the storage and the stored value.

The operations defined for a type are the only way to  manipulate its instantiated objects.

type error is any attempt to manipulate objects with illegal operations.

A program is type safe (or type secure) if it is guaranteed to have no type errors.

类型检查指验证操作接收的是否为合适的类型数据以及赋值是否合乎类型要求。

数据类型

编辑

数据类型是程序设计语言中的一个重要概念。类型的引入有着如下基本动机:

(1)类型可帮助更好地理解和组织关于客观对象的思想;

(2)类型系统可帮助了解和讨论某些特殊类型的独特性质;

(3)类型可帮助检测错误,防止对象的不合适使用。

大多数程序设计语言都使用类型系统来分类数据并防止错误,程序中的类型信息一方面增加了程序的易读性,另一方面也用于防止无意义的程序构造。

类型错误是主要的程序错误。类型错有两种原因:一是某操作收到错误类型的操作数;二是附类型变量的错误使用,即将其他类型的值存入某附类型变量中。为防止类型错误,类型检查是必要的。 [1] 

为了进行类型检查,编译器需要给源程序的侮一个组成部分赋予一个类型表达式。然后,编译器要确定这些类型表达式是否满足一组逻辑规则。这些规则称为源语言的类型系统。

https://www.zhihu.com/question/23434097

猜你喜欢

转载自www.cnblogs.com/feng9exe/p/10590035.html