skip to main content
article
Free access

The design of a class mechanism for Moby

Published: 01 May 1999 Publication History

Abstract

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.

References

[1]
Amadio, R. M. and L. Cardelli. Subtyping recursive types. ACM Transactions on Programming Languages and Systems, 15(4), September 1993, pp. 575-631.
[2]
Abadi, M. and L. Cardelli. A Theory of Objects. Springer- Verlag, New York, NY, 1996.
[3]
Arnold, K. and J. Gosling~ The Java Programming Language. Addison-Wesley, Reading, MA, 2nd edition, 1998.
[4]
Brace, K., L. Cardelli, G. Castagna, The Hopkins Object Group, G. Leavens, and B. Pierce. On binary methods. TAPOS, 1(3), 1996, pp. 221-242.
[5]
Brace, K. B., A. Fiech, and L. Petersen. Subtyping is not a good "match" for object-oriented languages, in ECOOP'97, vol. 1241 of LNCS, New York, NY, 1997. Springer-Verlag, pp. 104-127.
[6]
Bruce, K. B., L. Petersen, and J. ~anderwaart. Modules in LOOM: Classes are not enough. Available from http: //www. cs. williams, edu/~kim, April 1998.
[7]
Bruce, K., A. Schuett, and R. van Gent. PolyTOIL: A typesafe polymorphic object-oriented language. In ECOOP'95, vol. 952 of LNCS, New York, NY, 1995. Spfinger-Verlag, pp. 26-51.
[8]
Cardelli, L., J. Donahue, L. Glassman, M. Jordan, B. Kalsow, and G. Nelson. Modula-3 report (revised). Technical Report 52, Digital System Research Center, Palo Alto, CA, November 1989.
[9]
Cook, W. R., W. L. Hill, and P. S. Canning. Inheritance is not subtyping. In POPL'90, January 1990, pp. 125-135.
[10]
Cook, W. R. A proposal for making Eiffel type-safe. In ECOOP'89, 1989, pp. 57-72.
[11]
Fisher, K. Type Systems for Object-oriented Programming Langauges. Ph.D. dissertation, Stanford University, August 1996.
[12]
Fisher, K. and J. Mitchell. The development of type systems for object-oriented languages. Theory and Practice of Object Systems, 1(3), 1995, pp. 189-220.
[13]
Fisher, K. and J. Reppy. Foundations for MOB Y classes. Technical Memorandum, Bell Labs, Lucent Technologies, Murray Hill, NJ, February 1999.
[14]
Gosling, J., B. Joy, and G. Steele. The Java Language Specification. Addison-Wesley, Reading, MA, 1996.
[15]
Harper, R. and M. Lillibridge. A type-theoretic approach to higher-order modules with sharing. In POPL'94, January 1994, pp. 123-137.
[16]
Harper, R. and C. Stone. An interpretation of Standard ML in type theory. Technical Report CMU-CS-97-147, School of Computer Science, Carnegie Mellon University, Pittsburgh, PA, June 1997.
[17]
Inner classes specification, February 1997. Available from http: / / java. sun. com/products/jDK/1.1.
[18]
Katiyar, D., D. Luckham, and I. Mitchell. A type system for prototyping languages. In POPL'94, January 1994, pp. 138- 161.
[19]
Leroy, X. Manifest types, modules, and separate compilation. In POPL'94, January 1994, pp. 109-122.
[20]
Leroy, X. A syntacfc theory of type generativity and sharing. JFP, 6(5), September 1996, pp. 1-32.
[21]
Leroy, X. The Objective Caml System (release 2.00), August 1998. Available from http: //pauillac. inria, fr/caml.
[22]
MacQueen, D. Modules for Standard ML. In LFP'84, August 1984, pp. 198-207.
[23]
Milner, R., M. Torte, R. Harper, and D. MacQueen. The Definition of Standard ML (Revised). The MIT Press, Cambridge, MA, 1997.
[24]
Programming Methodology Group, MIT LCS, Cambridge, MA. Theta Reference Manual (Preliminary Version), February 1995. Available from httD: //www .pmg. lcs .mit. edu/Theta, html.
[25]
Pierce, B. C, and D. N. Turner. Statically typed friendly functions via partially abstract types. Technical Report ECS-LFCS-93-256, University of Edinburgh, LFCS, April 1993. Also available as INRIA-Rocquencourt Rapport de Recherche No. 1899.
[26]
Pierce, B. C. and D. N. Turner. Local type inference. In POPL'98, January 1998, pp. 252-265.
[27]
Rtmy, D. Type inference for records in a natural extension of ML. In C. A. Gunter and J. C. Mitchell (eds.), Theoretical Aspects of Object-oriented Programming, pp. 67-95. The MIT Press, Cambridge, MA, 1994.
[28]
Reppy, J. H. and J. G. Riecke. Classes in Object ML via modules. In FOOL3, July 1996.
[29]
Reppy, J. H. and J. G. Riecke. Simple objects for SML. In PLDI'96, May 1996, pp. 171-180.
[30]
Riecke, J. G. and C. Stone. Privacy via subsumpfion. In FOOL5, January 1998. A longer version will appear in TAPOS.
[31]
Rtmy, D. and J. Vouillon. Objective ML: An effective objectoriented extension to ML. TAPOS, 4, 1998, pp. 27-50.
[32]
Stroustrup, B. The Design and Evolution of C,+. Addison- Wesley, Reading, MA, 1994.
[33]
Stroustrup, B. The C++ Programming Language. Addison- Wesley, Reading, MA, 3rd edition, 1997.
[34]
Szyperski, C. A. Import is not inheritance; why we need both: Modules and classes. In ECOOP'92, 1992, pp. 19-32.
[35]
Vouillon, J. Using modules as classes. In FOOL5, January 1998.

Cited By

View all

Recommendations

Comments

Information & Contributors

Information

Published In

cover image ACM SIGPLAN Notices
ACM SIGPLAN Notices  Volume 34, Issue 5
May 1999
304 pages
ISSN:0362-1340
EISSN:1558-1160
DOI:10.1145/301631
Issue’s Table of Contents
  • cover image ACM Conferences
    PLDI '99: Proceedings of the ACM SIGPLAN 1999 conference on Programming language design and implementation
    May 1999
    304 pages
    ISBN:1581130945
    DOI:10.1145/301618
Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

Publisher

Association for Computing Machinery

New York, NY, United States

Publication History

Published: 01 May 1999
Published in SIGPLAN Volume 34, Issue 5

Check for updates

Qualifiers

  • Article

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • Downloads (Last 12 months)98
  • Downloads (Last 6 weeks)19
Reflects downloads up to 05 Jan 2025

Other Metrics

Citations

Cited By

View all

View Options

View options

PDF

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

Login options

Media

Figures

Other

Tables

Share

Share

Share this Publication link

Share on social media