Linear type systems permit programmers to deallocate or explicitly recycle memory, but are severely restricted by the fact that they admit no aliasing. This paper describes a pseudo-linear type system that allows a degree of aliasing and memory reuse as well as the ability to de ne complex recursive data structures. Our type system can encode conventional linear data structures such as linear lists and trees as well as more sophisticated data structures including cyclic and doubly-linked lists and trees. In the latter cases, our type system is expressive enough to represent pointer aliasing and yet safely permit destructive operations such as object deallocation. We demonstrate the exibility of our type system by encoding two common space-conscious algorithms: destination-passing style and Deutsch-Schorr-Waite or \link-reversal" traversal algorithms. 1 Introduction Type-safe programming languages, such as Haskell, Java, and ML, do not give programmers control over memory management. In particular, these languages do not allow programmers to separate allocation and initialization of memory objects, nor do they allow explicit re-use of memory objects. Rather, allocation and initialization of objects are presented to the programmer as an atomic operation, and re-use of memory is achieved \under the covers" through garbage collection. In other words, memory management is achieved by meta-linguistic mechanisms that are largely outside the control of the programmer. In type-unsafe languages such as C or C++, programmers have control over memory management so they can tailor routines for application-speci c constraints, where the time and/or space overheads of general-purpose memory management mechanisms do not su ce. However, such languages have a far more complicated and error-prone programming model. In particular, neither the static type systems, the compilers, nor the run-time systems of these languages prevent the accidental use of uninitialized objects, or the accidental re-use of memory at an incompatible type. Such errors are extremely costly to diagnose and correct. Our ultimate goal is to provide support for programmercontrolled memory management, without sacri cing typesafety, and without incurring signi cant overhead. In addition, we hope to discover general typing mechanisms and principles that allow greater lattitude in the design of lowlevel languages intended for systems applications or as the target of certifying compilers 28, 30] . In this paper, we
A related work REF introduces the notion of alias types to model mutable data structures such as linked lists.
Alias Types for Recursive Data Structures
In Workshop on Types in Compilation
Computer Science