An Operational Approach to the Semantics of Classes: Application to Type Checking

  • Authors:
  • J.-C. Royer

  • Affiliations:
  • Equipe Algorithmique, Specifications et Contraintes, Institut de Recherche en Informatique de Nantes 2, rue de la Houssiniére, BP 92208, 44322 Nantes Cedex 03 Jean-Claude.Royer@irin.u ...

  • Venue:
  • Programming and Computing Software
  • Year:
  • 2002

Quantified Score

Hi-index 0.00

Visualization

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.