Tangent(0.3 spec) uses something akin to this. (disclaimer: this is my own little research project)
Currently with
acts as a union operator modelling inheritance, though pragmatism has made it not commutative. Once you introduce implementations to methods, a strict union of methods with the same name is often not what you want and impossible to do right anyways.
intersect
is supported that models type inference for something like foo(T,T)
where the parameters are different.
Complements were interesting, but led to partial types that seemed not so useful and/or troublesome to include correctly - so are not included.
I know there are a few other research languages I ran across that had something similar, but cannot remember them at the moment. The main issue is that the things aren't really useful without structural typing, which isn't terribly popular itself. The other is that you need some sort of kind (type of types) to store the constructed type, or else it's just shorthand for something that isn't particularly idiomatic without that capability. And that's far less common than even structural typing.
It's biased, and it's not much, but there it is.
CanWriteAndCompare extends Serializable, Comparable {}
) and I was thinking of how to generalize this. – Haldean Brown Nov 21 '12 at 0:43A
or aB
, with two implementations that look exactly the same. In the method I'm calling a polymorphic method that can take anA
or aB
, so the implementations are the same, but since I have to take two distinct types I need two implementations. This would be easier if I could domyMethod(A | B aOrB)
. – Haldean Brown Nov 21 '12 at 0:45Or
operation can be emulated by multiple inheritance. – user Nov 21 '12 at 5:42