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?

keiter
  • 3,534
  • 28
  • 38

3 Answers3

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

smac89
  • 39,374
  • 15
  • 132
  • 179
michid
  • 10,536
  • 3
  • 32
  • 59
4

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

smac89
  • 39,374
  • 15
  • 132
  • 179
axel22
  • 32,045
  • 9
  • 125
  • 137
-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.

Basilevs
  • 22,440
  • 15
  • 57
  • 102