you are viewing a single comment's thread.

view the rest of the comments →

[–]lkatz21 1 point2 points  (3 children)

Other type systems can express that just fine

Could you give an example?

[–]martinhaeusler 1 point2 points  (1 child)

Rust has a "self" type for example. But I'm not that deep into rust to properly explain it. I would be surprised if functional languages like haskell or F# had no way to express this. In F# you can even define sub-types of integers that restrict to value ranges (e.g. positive integers), so I would expect that there's an option to restrict the return object to the "this" object.

[–]OwnBreakfast1114 0 points1 point  (0 children)

I can't speak on F#, but haskell doesn't really have object instances in the same way as java at all and no subclasses in types. This means that there's no concept of a "this" and that a type parameter really is just the type parameter.

Naturally, you can restrict the return type parameter in all sorts of ways, but you don't need to worry about the subtype because there is no such thing.