【发布时间】:2012-05-12 02:22:27
【问题描述】:
我现在正在深入阅读 Scala。以下是本书的摘录:
所有依赖路径的类型都是类型投影。一个依赖路径的类型
foo.Bar被重写 编译器为foo.type#Bar...在 Scala 中,所有类型引用都可以编写为针对命名实体的项目。 scala.String 类型是
scala.type#String的简写,其中名称scala指的是包scala,类型String由scala 包上的String类定义。
显然,没有 scala.String 类,但我无法使用 Null 重现这一点。
scala> type N = scala.type#Null
<console>:7: error: type mismatch;
found : type
required: AnyRef
type N = scala.type#Null
所以,我的问题如下。路径相关类型是类型投影吗?它只是内部编译器表示还是可以用scala代码表示?
【问题讨论】:
标签: scala types projection path-dependent-type