A Theory of Linear Objects

Matthew Kehrt and Jonathan Aldrich

Abstract

Recently, linearity has been proposed as a mechanism for memory management, alias control, and typestate tracking. While linear type systems have been extensively studied in functional programming, their use in object-oriented systems has been limited to useful but ad-hoc annotation systems that track unique pointers. In this paper, we study object-oriented linearity at level of foundational object calculi. Our system tracks not only linear objects (to which there may be only one pointer), but linear methods as well (which may be called at most once). Tracking linear objects allows us to ensure type safety for imperative, type-changing update to methods and imperative, type-changing dynamic inheritance. Because some aliasing is important in practical systems, our system supports linear and non-linear objects and methods and a novel region system that permits borrowed aliases to linear objects. To enforce safety, we allow type-changing modifications only on unborrowed linear objects, but permit such changes again when these borrowed references are no longer accessible.

Full paper

o

Presented at FOOL'08; Sunday, 13 January 2007; San Francisco, California, USA.