Adoption and focus: practical linear types for imperative programming

A type system with linearity is useful for checking software protocols andresource management at compile time. Linearity provides powerful reasoning about state changes, but at the price of restrictions on aliasing. The hard division between linear and nonlinear types forces the programmer to make a trade-off between checking a protocol on an object and aliasing the object. Most onerous is the restriction that any type with a linear component must itself be linear. Because of this, checking a protocol on an object imposes aliasing restrictions on any data structure that directly or indirectly points to the object. We propose a new type system that reduces these restrictions with the adoption and focus constructs. Adoption safely allows a programmer to alias objects on which she is checking protocols, and focus allows the reverse. A programmer can alias data structures that point to linear objects and use focus for safe access to those objects. We discuss how we implemented these ideas in the Vault programming language.

[1]  Peter W. O'Hearn,et al.  BI as an assertion language for mutable data structures , 2001, POPL '01.

[2]  David Gay,et al.  Memory management with explicit regions , 1998, PLDI.

[3]  David Walker,et al.  Typed memory management in a calculus of capabilities , 1999, POPL '99.

[4]  Martin Odersky Observers for Linear Types , 1992, ESOP.

[5]  Philip Wadler,et al.  Linear Types can Change the World! , 1990, Programming Concepts and Methods.

[6]  Robert DeLine,et al.  Enforcing high-level protocols in low-level software , 2001, PLDI '01.

[7]  David Walker,et al.  Alias Types , 2000, ESOP.

[8]  Martin Elsman,et al.  Programming with regions in the ML Kit , 1997 .

[9]  B. E. Eckbo,et al.  Appendix , 1826, Epilepsy Research.

[10]  Robert E. Strom,et al.  Typestate: A programming language concept for enhancing software reliability , 1986, IEEE Transactions on Software Engineering.

[11]  Marko C. J. D. van Eekelen,et al.  Guaranteeing Safe Destructive Updates Through a Type System with Uniqueness Information for Graphs , 1993, Dagstuhl Seminar on Graph Transformations in Computer Science.

[12]  John Tang Boyland,et al.  Alias burying: Unique variables without destructive reads , 2001, Softw. Pract. Exp..

[13]  Reinhard Wilhelm,et al.  Parametric shape analysis via 3-valued logic , 1999, POPL '99.

[14]  Fritz Henglein,et al.  A direct approach to control-flow sensitive region-based memory management , 2001, PPDP '01.

[15]  Mads Tofte,et al.  Implementation of the typed call-by-value λ-calculus using a stack of regions , 1994, POPL '94.

[16]  David Walker,et al.  Alias Types for Recursive Data Structures , 2000, Types in Compilation.

[17]  Viktor Kuncak,et al.  Role analysis , 2002, POPL '02.

[18]  K. Rustan M. Leino,et al.  Data abstraction and information hiding , 2002, TOPL.