我们在 类型(第2章) 中已经学习了不同的类型,现在来看看它们之间如何交互。我们先简单介绍一下 typedef(第3.1节) ,这是一种给一个复杂的类型命名(或别名)的机制。有许多用法,其中当处理有类型参数(第3.2节)的类型时,使用 typedef 会十分方便。
We learned about the different kinds of types in Types and it is now time to see how they interact with each other. We start off easy by introducing typedef, a mechanism to give a name (or alias) to a more complex type. Among other use cases, typedefs will come in handy when working with types that have type parameters.
通过检查两个给定类型之间是否兼容,类型安全性有了显著提升。这意味着编译器会尝试对它们执行一致性检查,更多细节将在 一致性检查(第3.5节)中展开。
A significant amount of type-safety is achieved by checking if two given types are compatible. Meaning, the compiler tries to perform unification between them as detailed in Unification.
所有的类型以模块的形式组织,且可以通过路径进行定位。 模块和路径(第3.7节) 中会详细解释相关的机制。
All types are organized in modules and can be addressed through paths. Modules and Paths will give a detailed explanation of the related mechanics.