Why does Scala have path-dependent types?
Asked Answered
S

3

14

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

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.

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.

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

Seismo answered 7/4, 2011 at 13:26 Comment(0)
W
9

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".

Wainscot answered 7/4, 2011 at 15:2 Comment(0)
T
4

This paper explains it nicely. Basically, they're used to support abstract data type based programming and modularization.

Tallow answered 7/4, 2011 at 14:8 Comment(2)
CMIIW, but this paper seems to have absolutely nothing to do with path-dependent types.Metre
True - this should have linked to the Scalable Component Abstractions paper.Tallow
E
-8

Think about L as about type argument of generic class. Scala boasts about its type members but underlying JVM still has the same limitations.

Excurved answered 7/4, 2011 at 13:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.