Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does Scala have path-dependent types?

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?

like image 793
keiter Avatar asked Apr 07 '11 13:04

keiter


1 Answers

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

like image 63
michid Avatar answered Oct 03 '22 23:10

michid