On interfaces

In Java, interfaces differ from classes primarily in a lack of inheritance: declarations are “inherited” but not in the same sense that methods are inherited between classes. Interface implementation is a matter of concern only to the Java type system, whereas with class inheritance the runtime environment needs to be aware of the inherited methods. This leads to the extra dimension of extension between classes and interfaces, denoted by the `implements` keyword. Since classes can only extend a single super class (i.e. there is no multiple inheritance in Java), interfaces statically enforce the existence of implementations of multiple sets of declarations, but they don’t say anything about what or where those implementations are.

However in a language like Fortress with multiple inheritance, the Java interface becomes obsolete. Not only can you express the same type and inheritance hierarchies as in Java, but you can even include definitions in these multiple inherited traits. Eat it, Java. But another question about dimensions of extension needs to be answered: What is the difference between `Reflexive extends BinaryPredicate` and `String extends Reflexive`? (Assume that we are only considering a single such operation `=` of String that is reflexive.)

The former extension conveys a familiar subset relation: anything that is a Reflexive is also a BinaryPredicate. The difference reveals itself in the latter extension — something along the lines of “a value of type String has an `=` operation which is reflexive” rather than “every value of type String also has type Reflexive.” Why does the second statement seem strange? Well, it doesn’t feel right to say that a value has type Reflexive; Reflexive is more a description of the entire type String than of the single value. (We could also say that `Reflexive T` is a qualified type, but this steers the discussion away from object land and towards functional land.)

The next step then is to consider the type String — rather than a value of type String — as having the Reflexive property. But what does this mean? A value has the property String which in turn has the property Reflexive. The relation between String and Reflexive conveys one of set membership rather than subset.

In the unrestricted world of metaclasses, we would say that String has kind Reflexive, which extends BinaryPredicate in the usual sense. But in Java, if we could, we might say that String implements the interface Reflexive, which declares the static method `=`. This would require the String class to implement a static method `=` so that this operation is no longer tied to individual values but to the entire String class itself.

It is this last meaning that I hope to describe, motivate, and implement on top of Fortress.