The design of a class mechanism for Moby

Abstract

Typical class-based languages, such as C++ and Java, provide complex class mechanisms but only weak module mechanisms. In fact, classes in these languages incorporate many of the features found in richer module mechanisms. In this paper, we describe an alternative approach to designing a language that has both classes and modules. In our design, we rely on a rich ML-style module system to provide features such as visibility control and parameterization, while providing a minimal class mechanism that includes only those features needed to support inheritance. Programmers can then use the combination of modules and classes to implement the full range of class-based features and idioms. Our approach has the advantage that it provides a full-featured module system (useful in its own right), while keeping the class mechanism quite simple.

We have incorporated this design in Moby, which is an ML-style language that supports class-based object-oriented programming. In this paper, we describe our design via a series of simple examples, show how various class-based features and idioms are realized in Moby, compare our design with others, and sketch its formal semantics.


Last modified: April 6, 2004.
Comments to: John Reppy
Copyright © 1999, ACM, Inc.