类型安全

如何理解编程语言的类型安全性?

在oreilly新出的免费电子书《Why Rust?》oreilly.com 的页面中,对于类型安全有如下定义:

If a program has been written so that no possible execution can exhibit undefined behavior, we say that program is well defined. If a language’s type system ensures that every program is well defined, we say that language is type safe.

(引自第四页第二段)

简单翻译就是说如果这个语言的类型系统能够保证所有程序都不会出现未定义行为,那么这个语言就是类型安全的。可是在我的理解中,并不是所有的未定义行为都是与类型系统相关啊。

类型安全就是说,同一段内存,在不同的地方,会被强制要求使用相同的办法来解释(interpret)

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

原文地址:https://www.cnblogs.com/feng9exe/p/10590038.html