A Language for Role Specifications Viktor Kuncak, Patrick Lam, and Martin Rinard Laboratory for Computer Science Massachusetts Institute of Technology Cambridge, MA 02139 {vkuncak, plam, rinard}@lcs.mit.edu Abstract. This paper presents a new language for identifying the chang- ing roles that objects play over the course of the computation. Each ob- ject’s points-to relationships with other objects determine the role that it currently plays. Roles therefore reflect the object’s membership in specific data structures, with the object’s role changing as it moves between data structures. We provide a programming model which allows the developer to specify the roles of objects at different points in the computation. The model also allows the developer to specify the effect of each operation at the granularity of role changes that occur in identified regions of the heap. 1 Introduction In standard type systems for object-oriented languages, each object is created as an instance of a specific class, with the object’s type determined by that class. Because the object’s class does not change, the object has the same type for its entire existence in the computation. This property limits the ability of the type system to capture dynamically changing object properties. Specifically, a given object may play many different roles during its lifetime in the computation, with the distinctions between these roles crucial to the computation’s safety and correctness. The inability of the type system to model these changing roles prevents it from capturing these important distinctions. This paper presents a new kind of type system, called a role system, which enables a developer to express the different roles that each object plays during its lifetime in the computation. The role of each object is determined by its points- to relationships with other objects. As these relationships change, the object’s type changes to reflect its changing role in the computation. Our system can therefore capture important distinctions between objects of the same class as they play different roles in the computation. Because roles are determined by the linking relationships, role changes often correspond to movements between data structures. Our role system is therefore ⋆ This research was supported in part by DARPA Contract F33615-00-C-1692, NSF Grant CCR00-86154, NSF Grant CCR00-63513, and an NSERC graduate scholar- ship.