Skip to main content
×
×
Home

A type system with usage aspects

  • DAVID ASPINALL (a1), MARTIN HOFMANN (a2) and MICHAL KONEČNÝ (a3)
Abstract

Linear typing schemes can be used to guarantee non-interference and so the soundness of in-place update with respect to a functional semantics. But linear schemes are restrictive in practice, and more restrictive than necessary to guarantee soundness of in-place update. This limitation has prompted research into static analysis and more sophisticated typing disciplines to determine when in-place update may be safely used, or to combine linear and non-linear schemes. Here we contribute to this direction by defining a new typing scheme that better approximates the semantic property of soundness of in-place update for a functional semantics. We begin from the observation that some data are used only in a “read-only” context, after which it may be safely re-used before being destroyed. Formalising the in-place update interpretation in a machine model semantics allows us to refine this observation, motivating three usage aspects apparent from the semantics that are used to annotate function argument types. The aspects are (1) used destructively, (2), used read-only but shared with result, and (3) used read-only and not shared with the result. The main novelty is aspect (2), which allows a linear value to be safely read and even aliased with a result of a function without being consumed. This novelty makes our type system more expressive than previous systems for functional languages in the literature. The system remains simple and intuitive, but it enjoys a strong soundness property whose proof is non-trivial. Moreover, our analysis features principal types and feasible type reconstruction, as shown in M. Konečn'y (In TYPES 2002 workshop, Nijmegen, Proceedings, Springer-Verlag, 2003).

Copyright
References
Hide All
Wikipedia article on the administrative normal form. (2007). http:\\en.wikipedia.org wiki/Administrative_Normal_Form. Accessed March 27, 2007.
Aiken, A., Foster, J. S., Kodumal, J. & Terauchi, T. (2003). Checking and inferring local non-aliasing. In PLDI '03: Proceedings of the ACM SIGPLAN 2003 Conference on Programming Language Design and Implementation. New York: ACM Press, pp. 129140.
Aspinall, D. & Compagnoni, A. (2003). Heap-bounded assembly language. J. Automated Reason. 31 (3/4), 261302.
Aspinall, D. & Hofmann, M. (2002). Another type system for in-place update. In Programming Languages and Systems, Proceedings of 11th European Symposium on Programming, D. L. Métayer (ed), Springer-Verlag. Lecture Notes in Computer Science 2305.
Aspinall, D. & Konevcný, M. (2003, February). Type Systems for Resource Bounded Programming and Compilation Project Homepage. http://homepages.inf.ed.ac.uk/da/resbnd. Accessed 1 June 2007.
Barendsen, E. & Smetsers, S. (1996). Uniqueness typing for functional languages with graph rewriting semantics. Math. Struct. Comput. Sci. 6, 579612.
Boyland, J. (2003). Checking interference with fractional permissions. In Static Analysis: 10th International Symposium, Cousot, R. (ed), Lecture Notes in Computer Science, vol. 2694. Berlin, Heidelberg, New York: Springer, pp. 5572.
Crary, K., Walker, D. & Morrisett, G. (1999). Typed memory management in a calculus of capabilities. In Proceedings ACM Principles of Programming Languages, Kobayashi: Hofmann & Jost, Istiaq & O'Hearn, pp. 262–275.
Dor, N., Rodeh, M. & Sagiv, M. (2000). Checking cleanness in linked lists. In Proceedings of the Seventh International Static Analysis Symposium. Springer, Berlin/Heidelberg, pp. 115–134. Lecture Notes in Computer Science 1824.
Draghicescu, M. & Purushothaman, S. (1993). A uniform treatment of order of evaluation and aggregate update. Theor. Comput. Sci. 118 (2), 231262.
Evans, D. (1996). Static detection of dynamic memory errors. In PLDI '96: Proceedings of the ACM SIGPLAN 1996 Conference on Programming Language Design and Implementation. New York: ACM Press, pp. 44–53.
Fahndrich, M. & DeLine, R. (2002). Adoption and focus: Practical linear types for imperative programming. In Pldi '02: Proceedings of the ACM Sigplan 2002 Conference on Programming Language Design and Implementation. New York: ACM Press, pp. 13–24.
Gifford, D. K., & Lucassen, J. M. (1986). Integrating functional and imperative programming. LFP '86: Proceedings of the 1986 ACM Conference on LISP and Functional Programming. New York: ACM Press, pp. 2838.
Hofmann, M. (2000). A type system for bounded space and functional in-place update. Nordic J. Comput., 7 (4), 258289. An extended abstract has appeared in Programming Languages and Systems, G. Smolka, ed., Springer LNCS, 2000.
Hofmann, M. & Jost, S. (2003). Static prediction of heap space usage for first-order functional programs. In 30th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Langauges (POPL '03), New York: ACM Press, pp. 185197.
Ishtiaq, S. & O'Hearn, P. W. (2001). BI as an assertion language for mutable data structures. The 28th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL '01), New York: ACM Press, pp. 1426.
Kobayashi, N. (1998). Quasi-linear Types. Tech. rept. 98–02. Department of Information Science, University of Tokyo.
Kobayashi, N. (1999). Quasi-linear types. 26th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL '99), New York: ACM Press, pp. 2942.
Konečný, M. (2003a). Functional in-place update with layered datatype sharing. TLCA 2003, Valencia, Spain, Proceedings. Springer-Verlag, pp. 195–210. Lecture Notes in Computer Science 2701.
Konečný, M. (2003b). Typing with conditions and guarantees for functional in-place update. In TYPES 2002 Workshop, Nijmegen, Proceedings. Springer-Verlag, pp. 182–199. Lecture Notes in Computer Science 2646.
MacKenzie, K. & Wolverson, N. (2004). Camelot and grail: resource-aware functional programming on the JVM. Trends in Functional Programing, Vol. 4. Bristol: Intellect, pp. 29–46.
Odersky, M. (1992). Observers for linear types. 4th European Symposium on Programming (ESOP '92), B. Krieg-Brückner (ed), Rennes, France: Springer-Verlag, pp. 390–407. Lecture Notes in Computer Science 582.
O'Hearn, P. W., Takeyama, M., Power, A. J., & Tennent, R. D. (1995). Syntactic control of interference revisited. In MFPS XI, Conference on Mathematical Foundations of Program Semantics. Electronic Notes in Theoretical Computer Science, vol. 1. Elsevier.
Peyton, J. S. & Wansbrough, K. (2000, September). Simple usage polymorphism. In Proc. 3rd ACM SIGPLAN Workshop on Types in Compilation (TIC 2000). Technical Report CMU–CS–00–161.
Reynolds, J. C. (1978). Syntactic control of interference. Proceedings of the Fifth ACM Symposium on Principles of Programming Languages (POPL). Tucson, AZ: ACM Press, pp. 39–46.
Reynolds, J. C. (2002). Separation logic: A logic for shared mutable data structures. Proceedings of 17th annual IEEE Symposium on Logic in Computer Science (LICS'02), pp. 55–74.
Sabry, A. & Felleisen, M. (1993). Reasoning about programs in continuation-passing style. LISP and Symbolic Comput., 6 (3/4), 289360.
Shankar, N. (1999, November). Efficiently Executing PVS. Project report, Computer Science Laboratory, SRI International, Menlo Park, CA.
Smith, F., Walker, D. & Morrisett, G. (2000). Alias types. In: 9th European Symposium on Programming (ESOP'00), Smolka, G. (ed), Springer-Verlag, pp. 366381. Lecture Notes in Computer Science 1782.
Talpin, J.-P. & Jouvelot, P. (1994). The type and effect discipline. Inf. Comput., 111 (2), 245296.
Tofte, M., & Talpin, J.-P. (1997). Region-based memory management. Inf. Comput., 132 (2), 109176.
Wadler, P. (1990). Linear types can change the world. IFIP TC 2 Working Conference on Programming Concepts and Methods, M. Broy & C. B., Jones (eds), Sea of Gallilee, Israel: North-Holland, pp. 561–581.
Walker, D. & Morrisett, J. G. (2001). Alias types for recursive data structures. In TIC '00: Selected Papers from the Third International Workshop on Types in Compilation. London, UK: Springer-Verlag, pp. 177206.
Wand, M. & Clinger, W. D. (1998). Set constraints for destructive array update optimization. In Proc. IEEE International Conference on Computer Languages (ICCL'98), IEEE, pp. 184–193.
Wilhelm, R., Sagiv, M., & Reps, T. (2000). Shape analysis. In Proc. 9th International Conference on Compiler Construction (CC 2000). Springer-Verlag, pp. 1–70. Lecture Notes in Computer Science 1781.
Yang, H., & Reddy, U. (1997). Imperative lambda calculus revisited. Electronic manuscript.
Recommend this journal

Email your librarian or administrator to recommend adding this journal to your organisation's collection.

Journal of Functional Programming
  • ISSN: 0956-7968
  • EISSN: 1469-7653
  • URL: /core/journals/journal-of-functional-programming
Please enter your name
Please enter a valid email address
Who would you like to send this to? *
×

Metrics

Full text views

Total number of HTML views: 0
Total number of PDF views: 0 *
Loading metrics...

Abstract views

Total abstract views: 0 *
Loading metrics...

* Views captured on Cambridge Core between <date>. This data will be updated every 24 hours.

Usage data cannot currently be displayed

A type system with usage aspects

  • DAVID ASPINALL (a1), MARTIN HOFMANN (a2) and MICHAL KONEČNÝ (a3)
Submit a response

Discussions

No Discussions have been published for this article.

×

Reply to: Submit a response


Your details


Conflicting interests

Do you have any conflicting interests? *