Previous Contents Next
Conclusion

We have shown that several practical examples presented as a justification for the special treatment of virtual types can in fact be directly programmed in Ocaml. We achieved this result by decoupling related classes that had to be recursively defined, previously. Decoupling is made possible in Ocaml by the use of row variables. A few other languages that have both binary methods and structural types can also solve virtual types with parametric polymorphism, as easily.

Grouping can still be allowed, but as a notational convenience rather than as a fundamental and new construction. Given the simplicity and the additional flexibility that we have obtained by decoupling classes, we claim that parametric polymorphism and structural types are preferable to virtual types. Indeed, parametric polymorphism is well-established, easy-to-manipulate and expressive. Its strength is hereby reaffirmed. Structural types are also commonly used in type theory and almost exclusively used in higher-order type systems. However, declared types are still common among programming languages with weaker, usually non parametric, type systems. Our experience with virtual types certainly reinforces the importance of structural types. This may be an issue to consider seriously in the design of type systems for new programming languages.


Previous Contents Next