Abstract
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 define 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 flexibility of our type system by encoding two common space-conscious algorithms: destination-passing style and Deutsch-Schorr-Waite or “link-reversal” traversal algorithms.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Preview
Unable to display preview. Download preview PDF.
Similar content being viewed by others
References
Samson Abramsky. Computational interpretations of linear logic. Theoretical Computer Science, 111:3–57, 1993.
Alexander Aiken, Manuel Fähndrich, and Raph Levien. Better static memory management: Improving region-based analysis of higher-order languages. In ACM Conference on Programming Language Design and Implementation, pages 174–185, La Jolla, California, 1995.
Erik Barendsen and Sjaak Smetsers. Conventional and uniqueness typing in graph rewrite systems (extended abstract). In Thirteenth Conference on the Foundations of Software Technology and Theoretical Computer Science, pages 41–51, Bombay, 1993. In Shyamasundar, ed., Springer-Verlag, LNCS 761.
Michael Benedikt, Thomas Reps, and Mooly Sagiv. A decidable logic for describing linked data structures. In European Symposium on Programming, pages 2–19, Amsterdam, March 1999.
Lars Birkedal, Mads Tofte, and Magnus Vejlstrup. From region inference to von Neumann machines via region representation inference. In Twenty-Third ACM Symposium on Principles of Programming Languages, pages 171–183, St. Petersburg, January 1996.
Rodney M. Burstall. Some techniques for proving correctness of programs which alter data structures. In Bernard Meltzer and Donald Michie, editors, Machine Intelligence, pages 23–50, Edinburgh, 1972. Edinburgh University Press.
Perry Cheng and Chris Okasaki. Destination-passing style and generational garbage collection. Unpublished., November 1996.
Jawahar Chirimar, Carl A. Gunter, and Jon G. Riecke. Reference counting as a computational interpretation of linear logic. Journal of Functional Programming, 6(2):195–244, March 1996. 202 D. Walker and G. Morrisett
Stephen Cook and Derek Oppen. An assertion language for data structures. In Second ACM Symposium on Principles of Programming Languages, pages 160–166, New York, 1975. ACM Press.
Karl Crary, David Walker, and Greg Morrisett. Typed memory management in a calculus of capabilities. In Twenty-Sixth ACM Symposium on Principles of Programming Languages, pages 262–275, San Antonio, January 1999.
Alain Deutsch. Interprocedural may-alias analysis for pointers: Beyond k-limiting. In ACM Conference on Programming Language Design and Implementation, pages 230–241, Orlando, June 1994.
Rakesh Ghiya and Laurie J. Hendren. Is it a tree, a DAG, or a cyclic graph? A shape analysis for heap-directed pointers in C. In Twenty-Third ACM Symposium on Principles of Programming Languages, pages 1–15, St. Petersburg Beach, Florida, January 1996.
Jean-Yves Girard. Linear logic. Theoretical Computer Science, 50:1–102, 1987.
Dan Grossman and Greg Morrisett. Scalable certi cation for typed assembly language. In ACM SIGPLAN Workshop on Types in Compilation, Montreal, September 2000.
Juan C. Guzmán and Paul Hudak. Single-threaded polymorphic lambda calculus. In Symposium on Logic in Computer Science, pages 333–343, Philadelphia, June 1990. IEEE Computer Society Press.
Robert Harper. A simplified account of polymorphic references. Information Processing Letters, 51(4):201–206, August 1994.
Samin Ishtiaq and Peter O’Hearn. BI as an assertion language for mutable data structures. In Twenty-Eighth ACM Symposium on Principles of Programming Languages, pages 14–26, January 2001.
Neil D. Jones and Steven Muchnick, editors. Flow analysis and optimization of Lisp-like structures. Prentice-Hall, 1981.
Naoki Kobayashi. Quasi-linear types. In Twenty-Sixth ACM Symposium on Principles of Programming Languages, pages 29–42, San Antonio, January 1999.
Yves Lafont. The linear abstract machine. Theoretical Computer Science, 59:157–180, 1988.
James R. Larus and Paul N. Hil nger. Detecting conflicts between structure accesses. In ACM Conference on Programming Language Design and Implementation, pages 24–31, June 1988.
James Richard Larus. Restructuring Symbolic Programs for Concurrent Execution on Multiprocessors. PhD thesis, University of California at Berkeley, May 1989. Available as Berkeley technical report UCB/CSD 89/502.
Erik Meijer, Maarten Fokkinga, and Ross Paterson. Functional programming with bananas, lenses, envelopes, and barbed wire. In ACM Conference on Functional Programming and Computer Architecture, volume 523 of Lecture Notes in Computer Science, Berlin, 1991. Springer-Verlag.
Y. Minamide. A functional representation of data structures with a hole. In Twenty-Fifth ACM Symposium on Principles of Programming Languages, pages 75–84, San Diego, January 1998.
Y. Minamide, G. Morrisett, and R. Harper. Typed closure conversion. In Twenty-Third ACM Symposium on Principles of Programming Languages, pages 271–283, St. Petersburg, January 1996.
Bernhard Möller. Towards pointer algebra. Science of Computer Programming, 21:57–90, 1993. Alias Types for Recursive Data Structures 203
Greg Morrisett, Karl Crary, Neal Glew, and David Walker. Stack-based Typed Assembly Language. In Xavier Leroy and Atsushi Ohori, editors, Second International Workshop on Types in Compilation, volume 1473 of Lecture Notes in Computer Science, pages 28–52, Kyoto, March 1998. Springer-Verlag.
Greg Morrisett, David Walker, Karl Crary, and Neal Glew. From System F to Typed Assembly Language. In Twenty-Fifth ACM Symposium on Principles of Programming Languages, pages 85–97, San Diego, January 1998.
Greg Morrisett, David Walker, Karl Crary, and Neal Glew. From System F to Typed Assembly Language. ACM Transactions on Programming Languages and Systems, 3(21):528–569, May 1999.
George Necula and Peter Lee. The design and implementation of a certifying compiler. In ACM Conference on Programming Language Design and Implementation, pages 333–344, Montreal, June 1998.
John C. Reynolds. Syntactic control of interference. In Fifth ACM Symposium on Principles of Programming Languages, pages 39–46, Tucson, 1978.
John C. Reynolds. Intuitionistic reasoning about shared mutable data structure. In Millennial Perspectives in Computer Science, Palgrove, 2000.
Mooly Sagiv, Thomas Reps, and Reinhard Wilhelm. Solving shape-analysis problems in languages with destructive updating. ACM Transactions on Programming Languages and Systems, 20(1):1–50, January 1998.
Mooly Sagiv, Thomas Reps, and Reinhard Wilhelm. Parametric shape analysis via 3-valued logic. In Twenty-Sixth ACM Symposium on Principles of Programming Languages, pages 105–118, San Antonio, January 1999.
H. Schorr and W. M. Waite. An efficient machine-independent procedure for garbage collection in various list structures. Communications of the ACM, 10(8):501–506, August 1967.
Frederick Smith, David Walker, and Greg Morrisett. Alias types. In European Symposium on Programming, volume 1782 of Lecture Notes in Computer Science, pages 366–381, Berlin, March 2000. Springer-Verlag.
Johnathan Sobel and Daniel Friedman. Recycling continuations. In ACM International Conference on Functional Programming, pages 251–260, Baltimore, September 1998.
TALx86. See http://www.cs.cornell.edu/talc for an implementation of Typed Assembly Language based on Intel’s IA32 architecture.
Mads Tofte and Jean-Pierre Talpin. Implementation of the typed call-by-value λ-calculus using a stack of regions. In Twenty-First ACM Symposium on Principles of Programming Languages, pages 188–201, Portland, Oregon, January 1994.
David N. Turner, Philip Wadler, and Christian Mossin. Once upon a type. In ACM International Conference on Functional Programming and Computer Architecture, San Diego, CA, June 1995.
Philip Wadler. Listlessness is Better than Laziness. PhD thesis, Carnegie Mellon University, August 1985. Available as Carnegie Mellon University technical report CMU-CS-85-171.
Philip Wadler. Linear types can change the world! In M. Broy and C. Jones, editors, Programming Concepts and Methods, Sea of Galilee, Israel, April 1990. North Holland. IFIP TC 2 Working Conference.
David Walker. Typed Memory Management. PhD thesis, Cornell University, January 2001. To appear.
Andrew K. Wright and Matthias Felleisen. A syntactic approach to type soundness. Information and Computation, 115(1):38–94, 1994. 204 D. Walker and G. Morrisett
Hongwei Xi. Dependent Types in Practical Programming. PhD thesis, Carnegie Mellon University, 1999.
Hongwei Xi and Frank Pfenning. Dependent types in practical programming. In Twenty-Sixth ACM Symposium on Principles of Programming Languages, pages 214–227, San Antonio, TX, January 1999.
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2001 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Walker, D., Morrisett, G. (2001). Alias Types for Recursive Data Structures. In: Harper, R. (eds) Types in Compilation. TIC 2000. Lecture Notes in Computer Science, vol 2071. Springer, Berlin, Heidelberg. https://doi.org/10.1007/3-540-45332-6_7
Download citation
DOI: https://doi.org/10.1007/3-540-45332-6_7
Published:
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-540-42196-2
Online ISBN: 978-3-540-45332-1
eBook Packages: Springer Book Archive