Gradual Typing
the gradual type checker 通过一个用 ?
表示的 unknow type (also called the dynamic type) 来处理 unannotated variables。
the gradual type checker 在两个类型间允许 implicit conversion 如果他们 consistent with each other (用 S ~ T
来表示 S is consistent with T,用 S !~ T
S is not consistent with T
- 对任意类型
T
有? ~ T
andT ~ ?
. 即允许?
与任何类型的相互 conversions - 对任意 basic type
B
, such as int, 有B ~ B
. - tuple type
T1 * T2
is consistent withS1 * S2
ifT1 ~ S1
andT2 ~ S2
. 这个规则被推广到任意大小的 tuple - 函数类型
fun (T1, ..., Tn) => R)
is consistent withfun (S1, ..., Sn) => U)
ifT1 ~ S1, ..., Tn ~ Sn
andR ~ U
.