The design of a class mechanism for Moby

Typical class-based languages, such as C++ and JAVA, provide complex class mechanisms but only weak module systems. 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.

[1]  Luca Cardelli,et al.  Subtyping recursive types , 1991, POPL '91.

[2]  John H. Reppy,et al.  Foundations for MOBY Classes , 1998 .

[3]  John C. Mitchell,et al.  The Development of Type Systems for Object-Oriented Languages , 1995, Theory Pract. Object Syst..

[4]  David B. MacQueen,et al.  The Definition of Standard ML (Revised) , 1997 .

[5]  Didier Rémy,et al.  Type inference for records in natural extension of ML , 1994 .

[6]  William R. Cook,et al.  A Proposal for Making Eiffel Type-Safe , 1989, Comput. J..

[7]  Kim B. Bruce,et al.  PolyTOIL: A Type-Safe Polymorphic Object-Oriented Language , 1995, ECOOP.

[8]  Luca Cardelli,et al.  On Binary Methods , 1995, Theory Pract. Object Syst..

[9]  Xavier Leroy,et al.  Manifest types, modules, and separate compilation , 1994, POPL '94.

[10]  Jerome Vouillon Using modules as classes , 1997 .

[11]  Robin Milner,et al.  Definition of standard ML , 1990 .

[12]  Benjamin C. Pierce,et al.  Statically typed friendly functions via partially abstract types , 1993 .

[13]  Xavier Leroy,et al.  A syntactic theory of type generativity and sharing , 1996, Journal of Functional Programming.

[14]  John C. Mitchell,et al.  A type system for prototyping languages , 1994, POPL '94.

[15]  Kim B. Bruce,et al.  Modules in LOOM: Classes are not enough , 1998 .

[16]  John C. Mitchell,et al.  Type systems for object-oriented programming languages , 1996 .

[17]  Benjamin C. Pierce,et al.  Local type inference , 1998, POPL '98.

[18]  Ken Arnold,et al.  The Java Programming Language , 1996 .

[19]  John H. Reppy,et al.  Simple objects for Standard ML , 1996, PLDI '96.

[20]  Kim B. Bruce,et al.  Subtyping Is Not a Good "Match" for Object-Oriented Languages , 1997, ECOOP.

[21]  Martín Abadi,et al.  A Theory of Objects , 1996, Monographs in Computer Science.

[22]  Didier Rémy,et al.  Objective ML: An Effective Object-Oriented Extension to ML , 1998, Theory Pract. Object Syst..

[23]  Ken Arnold,et al.  The Java programming language (2nd ed.) , 1998 .

[24]  Robert Harper,et al.  An Interpretation of Standard ML in Type Theory , 1997 .

[25]  Clemens A. Szyperski,et al.  Import is Not Inheritance - Why We Need Both: Modules and Classes , 1992, ECOOP.

[26]  Bjarne Stroustrup,et al.  C++ Programming Language , 1986, IEEE Softw..

[27]  Mark Lillibridge,et al.  A type-theoretic approach to higher-order modules with sharing , 1994, POPL '94.

[28]  Luca Cardelli,et al.  Modula-3 Report (revised) , 1992 .

[29]  John H. Reppy,et al.  Classes in Object ML via Modules , 1996 .

[30]  Bjarne Stroustrup,et al.  The Design and Evolution of C , 1994 .

[31]  Bjarne Stroustrup,et al.  The C++ programming language (2nd ed.) , 1991 .

[32]  William R. Cook,et al.  Inheritance is not subtyping , 1989, POPL '90.

[33]  David B. MacQueen Modules for standard ML , 1984, LFP '84.

[34]  Guy L. Steele,et al.  The Java Language Specification , 1996 .