Abstract
This paper presents a simple and natural semantics for object-oriented languages with classes and multiple inheritance. The model, called the Formal Class model, is an intermediate level between the algebraic specification of data type, and the implementation within an object-oriented language. Our model is equipped with an operational semantics based on conditional term rewriting. One important characteristic is the use of conditional selectors. It allows one to define a type with a flat or an ordered design. In this context, we define a safe and simple type system with single dispatch and simply covariant methods. This type system is extended to some practical aspects, such as abstract classes, abstract methods, protected methods, and super methods. We describe and compare flat and ordered designs and prove that the latter is finer than the former one. We also look at multicovariant methods and show ways to fix type-checking problems using single dispatch. We describe the least pessimistic solution. Lastly, we discuss the extension of our type checking to multiple dispatch and side effects. This paper synthesizes several practical results, their proofs, and algorithms.
Similar content being viewed by others
Explore related subjects
Discover the latest articles, news and stories from top researchers in related subjects.REFERENCES
Meyer, B., Object-oriented Software Construction, International Series in Computer Science, Prentice Hall, 1988.
Cook, W.R., A Proposal for Making Eiffel Type-safe, Comput. J., 1989, vol. 32, no. 4, pp. 305-311.
Mugridge, W., Hamer, J., and Hosking, J.G., Multimethods in a Statically-Typed Program Language, Proc. of ECOOP'91, Geneva, 1991, LNCS, Springer, 1991, vol. 512, pp. 307-324.
Agrawal, R., DeMichiel, L.G., and Lindsay, B.G., Static Type Checking of Multi-Methods, Proc. of OOPSLA'91, 1991, pp. 113-128.
Ghelli, G., A Static Type System for Message Passing, ACM SIGPLAN NOTICES, 1991, vol. 26, no. 11, pp. 129-145.
Oxhoj, N., Palsberg, J., and Schartzbach, M.I., Making Type Inference Practical, ECOOP'92, LNCS, 1992, vol. 615, pp. 329-349.
Chambers, C., Object-Oriented Multi-Methods in Cecil, ECOOP'92, Utrecht, LNCS, 1992, vol. 615, pp. 33-56.
Palsberg, J. and Schartzbach, M.I., Static Typing for Object-Oriented Programming, Sci. Comput. Programming, 1994, vol. 23, no. 1, pp. 19-53.
Chambers, C. and Leavens, G.T., Type Checking and Modules for Multi-Methods, OOPSLA'94, 1994.
Paslberg, J. and Schwartzbach, M.J., Object-Oriented Type Systems, Wiley, 1994.
Amiel, E., Bellosta, M.-J., Dujardin, E., and Simon, E., Type-Safe Relaxing of Schema Consistency Rules for Flexible Modelling in OODMBS, VLDB J., 1995.
Bruce, K., Cardelli, L., and Castagna, G., The Hopkins Object Group. Leavens, G.T. and Pierce, B., On Binary Methods, Theory Practice Object Systems, 1996, vol. 1, no. 3.
Abadi, M. and Cardelli, L., A Theory of Objects, Monographs in Computer Science, Springer, 1996.
Castagna, G., Object-Oriented Programming: A Unified Foundation, Number ISBN 3-7643-3905-5 in Progress in Theoretical Computer Science, Birkhauser, 1997.
Boyland, J. and Castagna, G., Type-Safe Compilation of Covariant Specialization: A Practical Case, Proc. of ECOOP'96, Springer, 1996.
Royer, J.-C., Type Checking Object-Oriented Programs: Core of the Problem and Some Solutions, J. Object-Oriented Programming, 1998, vol. 11, no. 6, pp. 58-66.
Cardelli, L., A Semantics of Multiple Inheritance, LNCS, 1984, vol. 173, pp. 131-144.
Wegner, P. and Bruce, K.B., An Algebraic Model of Subtypes in Object-Oriented Languages (draft), ACM Sigplan Notices, 1986, vol. 21, no. 10, pp. 163-172.
Cook, W., Hill, W.L., and Canning, P.S., Inheritance Is Not Subtyping, Proc. of the 1990 ACM Seventeenth Annual Symp. on POPL, ACM, 1990, pp. 125-135.
Mitchell, J.C., Toward a Typed Foundation for Method Specialisation and Inheritance, ACM Seventeenth Annual Symp. on POPL, ACM, 1990, pp. 109-124.
Pierce, B.C. and Turner, D.N., Simple Type-Theoretic Foundations for Object-Oriented Programming, J. Functional Programming, 1994, vol.4, no. 2, pp. 207-247.
Kaci, H.A. and Podelski, A., Towards a Meaning of Life. Research (Revised, October 1992) 11. Digital, Paris Research Laboratory, June 1991.
Hudak, P., Jones, S.P., Wadler, P., Arvind, Boutel, B., Fairbain, J., Fasel, J., Guzman, M.M., Hammond, K., Hughes, J., Jonhnsson, T., Kierburtz, R., Nikhil, R.S., Partain, W., and Peterson, J., Report on the Functional Programming Languages Haskell. Version 1.2, ACM SIGPLAN Notices, 1992, vol. 27, no. 5.
Abadi, M., Baby Modula-3 and a Theory of Objects, J. Functional Programming, 1994, vol. 2, no. 4.
Castagna, G., Overloading, Subtyping and Late Binding: Functional Foundation of Object-Oriented Programming, PhD Dissertation, Universite Paris VII, 1994.
Hudak, P. and Fasel, J.H., A Gentle Introduction to Haskell, ACM SIGPLAN Notices, 1992, vol. 27, no. 5, pp. T1-T53.
Castagna, G., Ghelli, G., and Longo, G., A Calculus for Overloaded Functions with Subtyping, ACM Conf. LISP and Functional Programming, San Francisco, 1992, ACM, pp. 182-192.
Kamin, S.N. and Reddy, U.S., Two Semantic Models of Object-Oriented Languages, Technical report, University of Illinois, Urbana-Champaign, 1991.
Plaindoux, D., Bodeveix, J.-P., and Percebois, C., Types Versus Classes, L'objet, 1998, vol. 4, no. 1, pp. 9-44.
Szypersky, C., Omohundo, S., and Murer, S., Engineering Programming Language: The Type and Class System of Sather, Programming Languages and System Architectures, LNCS, 1993, vol. 782, pp. 208-227.
Jouannaud, J.-P., Kirchner, C., Kirchner, H., and Megrelis, A., Programming with Equalities, Subsorts, Overloading and Parameterization in obj, J. Logic Programming, 1992, vol. 12, no. 3, pp. 257-280.
Kirchner, C., Kirchner, H., and Meseguer, J., Operational Semantics of OBJ3, Rapport de recherche 87-R-87, Centre de Recherche en Informatique de Nancy, Vandoevreles-Nancy, 1988.
André, P. and Royer, J.-C., La modelisation des listes en programmation par objets, Cointe, P., Queinnec, C., Serpette, B., (eds.), Journées Francophones des Langages Applicatifs (JFLA'94), 1994, no. 11 in Collection Didactique, pp. 259-285.
André, P., Chiorean, D., and Royer, J.-C., The Formal Class Model, Joint Modular Languages Conf., Modula, Oberon & friends, ISBN 3-89559-220-X. Ulm, Germany, 1994, pp. 59-78.
Choppy, C., Poizat, P., and Royer, J.-C., From Informal Requirements to COOP: A Concurrent Automata Approach, Wing, J.M., Woodcock, J., and Davies, J., Eds., FM'99-Formal Methods. World Congress on Formal Methods in the Development of Computing Systems, Lecture Notes in Computer Science, Springer, 1999, vol. 1709, pp. 939-962.
André, P., Romanczuk, A., Royer, J.-C., and Vasconcelos, A., An Algebraic View of UML Class Diagrams, Dony, H.S.C., Ed., Acte de la confe rence LMO'2000, ISBN 2-6462-0093-7, 2000, pp. 261-276.
37. Liang Peng, Romanczuk, A., and Royer, J.-C., A Practical Translation of UML Components into Formal Specifications, TOOLS East Europe 2002, 2002.
Meyer, B., Static Typing and Other Mysteries of Life, http://www.eiffel.com, 1995.
Chiorean, D., Cî rstea, C., and Royer, J.-C., Type Checking Formal Classes: Principles and Algorithms, Rapport de recherche 99, Institut de Recherche en Informatique de Nantes, 1995.
Boyland, J. and Castagna, G., Parasitic Methods: An Implementation of Multi-Methods for Java, Proc. of OOPSLA'97, SIGPLAN Notices, 1997, vol. 32, pp. 66-76.
Lécluse, C. and Richard, P., The O2 Database Programming Language, Apers, P.M.G. and Wiederhold, G., Eds., Proc. of the Fifteenth Int. Conf. on Very Large Data Bases, Amsterdam, 1989, Amsterdam: Morgan Kaufmann, 1989, pp. 411-422.
Castagna, G., Covariance and Contravariance: Conflict without a Cause, ACM Trans. Programming Languages Systems, 1995, vol. 17, pp. 1-17.
Royer, J.-C., A New Set Interpretation for the Inheritance Relation and Its Checking, ACM OOPS MESSENGER, 1992, vol. 3, no. 3, pp. 22-40.
Wirsing, M., Handbook of Theoretical Computer Science, Van Leeuwen, J., Ed., Vol. B: Algebraic SpecificationChapter 13, Elsevier, 1990, pp. 675-788.
Dershowitz, N., Jouannaud, J.-P., V. B., Rewrite Systems, in Handbook of Theoretical Computer Science, Van Leeuwen, J., Ed., Elsevier, 1990, pp. 243-320.
Klop, J.W., Handbook of Logic in Computer Science. Term Rewriting Systems, Oxford: Oxford University Press, 1992, pp. 1-117.
Gosling, J., Joy, B., Steele, G., and Bracha, G., The Java Language Specification Second Edition. The Java Series, Boston (Mass.): Addison-Wesley, 2000.
Poizat, P., Applications de la réécriture de termes aux modè les à objet, Master's thesis, DEA Informatique, Université de Nantes, 1995.
Meyer, B., Static Typing For Eiffel, Technical report, Interactive Software Engineering Inc, 1989.
Goguen, J.A. and Meseguer, J., Ordered-Sorted Algebra Solves the Constructor-Selector, Multiple Representation, and Coercions Problems, Proc. of Second Symp. on Logic in Computer Sci., IEEE Computer Society Press, 1987, pp. 18-29.
Hoare, C.A.R., Proof of Correctness of Data Representations, Acta Informatica1972, vol. 1, pp. 271-281.
Ingalls, D.H.H., A Simple Technique for Handling Multiple Polymorphism, Meyrowitz, N. (ed.), Proc. of the 1986 ACM Conf. on Object-Oriented Programming Systems, Languages and Applications, Portland, 1986, ACM SIGPLAN, pp. 347-349.
Johnson, R.E., Type-Checking Smalltalk, Proc. of the 1986 ACM Conf. on Object-Oriented Programming Systems, Languages and Applications, Portland, 1986, ACM, pp. 315-321.
Ducournau, R., Habib, M., Huchard, M., and Mugnier, M.-L., Monotonic Conflict Resolution Mechanisms for Inheritance, ACM OOSPLA Proc., 1992, pp. 16-24.
Amiel, E. and Dujardin, E., Un outil d'aide à la résolution explicite des ambigutés des multi-méthodes, Langages et modè les à objets, INRIA, 1995, pp. 131-152.
Author information
Authors and Affiliations
Rights and permissions
About this article
Cite this article
Royer, JC. An Operational Approach to the Semantics of Classes: Application to Type Checking. Programming and Computer Software 28, 127–147 (2002). https://doi.org/10.1023/A:1015632129995
Issue Date:
DOI: https://doi.org/10.1023/A:1015632129995