4 ms·
> There was a OO ML language called Moby [1] that had something similar. OCaml uses a structural object system (alongside the nominative type system it inherit
by masklinn 13y ago
> There was a OO ML language called Moby [1] that had something similar.
OCaml uses a structural object system (alongside the nominative type system it inherited from ML)
[0] http://en.wikipedia.org/wiki/OCaml http://en.wikipedia.org/wiki/OCaml
- seanmcdirmid 13y agoThey are pretty contemporary, from the 2003 Moby paper: > The main differences stem from a fundamental design choice: OCAML’s design emphasizes the expressiveness of the object-type system, whereas MOBY’s design emphasizes the expressiveness of the class system. OCAML uses row polymorphism [R´em94] to support extensible object types, whereas MOBY uses structural subtyping. OCAML’s approach has two advantages: it is backward compatible with ML’s Hindley-Milner type inference, and one can get the effect of mytype by the use of recursive type variables. The cost of providing mytype is that OCAML’s classes are less flexible than MOBY’s. Specifically, if a method is public in an OCAML class, it cannot be hidden from either class clients or object clients of a deriving class, as required for the soundness of mytype. In addition, if a method is hidden from object clients in a class, it cannot be made public by a deriving class. The former restriction means that the class hierarchy determines an object-type hierarchy. These restrictions, along with the fact that OCAML does not have public fields, limit one’s ability to use the module system to implement friends via package scope in two ways. First, it is not possible to reveal inherited protected methods or fields to the friend functions, and any method that a class reveals to its friends must also be revealed to any client outside the module (assuming that the class is exported).