Imperial College London
Sound Languages Underpin Reliable Programming

Overloading and Inheritance

Davide Ancona, Sophia Drossopoulou, Elena Zucca

More SLURP publications by these authors.
January 2001
Conference or Workshop Paper
Presented at 8th International Workshop on Foundations for Object Oriented Languages (FOOL 2001)
Tagged with the following topics:

See more SLURP publications with these topics.

Overloading allows several function definitions for the same name, distinguished primarily through different argument types; it is typically resolved at compile-time. Inheritance allows subclasses to define more special versions of the same function; it is typically resolved at run-time.

Modern object-oriented languages incorporate both features, usually in a type-safe manner. However, the combination of these features sometimes turns out to have surprising, and even counterintuitive, effects.

We discuss why we consider these effects inappropriate, and suggest alternatives. We explore the design space by isolating the main issues involved and analyzing their interplay and suggest a formal framework describing static overloading resolution and dynamic function selection, in a programming language, and their abstracting from other language features. We believe that our framework clarifies the thought process going on at language design level.

We introduce a notion of soundness and completeness of an overloading resolution policy w.r.t. the underlying dynamic semantics, and a way of comparing the flexibility of different resolution policies. We apply these concepts to some non-trivial issues raised in concrete languages.

We also argue that the semantics of overloading and inheritance is "clean" only if it can be understood through a copy semantics, whereby programs are transformed to equivalent programs without subclasses, and the effect of inheritance is obtained through copying.

Download Postscript of the full publication (189 kbytes)
Bibtex Entry