Typechecking and Modules for Multimethods
Abstract
Two major obstacles that hinder the wider acceptance of multimethods are (1) concerns over the lack of encapsulation and modularity and (2) the absence of static typechecking in existing multimethod-based languages.This article addresses both of these problems.We present a polynomial-time, static typechecking algorithm that checks the conformance, completeness, and consistency of a group of method implementations with respect to declared message signatures.This algorithm improves on previous algorithms by handling separate type and inheritance hierarchies, abstract classes, and graph-based method lookup semantics.We also present a module system that enables independently developed code to be fully encapsulated and statically typechecked on a per-module basis.To guarantee that potential conflicts between independently developed modules have been resolved, a simple well-formedness condition on the modules comprising a program is checked at link-time.The typechecking algorithm and module system are applicable to a range of multimethod-based languages, but the article uses the Cecil language as a concrete example of how they can be applied.