为什么 Scala 有路径依赖类型? [英] Why does Scala have path-dependent types?

查看:36
本文介绍了为什么 Scala 有路径依赖类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在研究路径依赖类型.我能找到的最好的描述是:

I've been doing some research on path-dependent types. The best description I could find for it was:

如果 L 是一个类型标签,那么 x.L 和 y.L 是相同的类型,如果 x 和 y 可以被证明是指同一个对象.

If L is a type label, then x.L and y.L are the same type iff x and y can be shown to refer to the same object.

这有时不是人们所期望的子类型行为.我希望如果上例中的 L 确实相同,那么这足以使 x.L 和 y.L 相同.

This sometimes isn't the subtyping behaviour one would expect. I would expect that if L in the above example was indeed identical then that would be enough to make x.L and y.L indentical.

Scala 被设计成这样有什么特别的原因吗?

Is there any particular reason why Scala was designed this way?

推荐答案

可扩展Component Abstractions 论文对路径依赖类型有很好的解释,也是第 3 节案例研究:主题/观察者"中的一个很好的例子.

The Scalable Component Abstractions paper has a good explanation on path dependent types and also a good example in Section 3: "Case study: subject/observer".

这篇关于为什么 Scala 有路径依赖类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆