Are there programming languages that allow you to do set arithmetic on types?
- by Will Brown
Out of curiosity, are there languages that allow you to do set arithmetic on types to create new types? Something like:
interface A {
void a();
void b();
}
interface B {
void b();
void c();
}
interface C = A & B; // has b()
interface D = A | B; // has a(), b() and c()
interface E = (A & B) ^ B; // has c()
I know that in some languages these ideas can be expressed (i.e., Java has List<Comparable & Serializable> for the union of the interfaces) but I've never heard of a language that supports type arithmetic. Thanks!