Skip to main content

Part of the book series: Lecture Notes in Computer Science ((LNCS,volume 523))

  • 223 Accesses

  • 9 Citations

Abstract

A criticism often levelled at functional languages is that they do not cope elegantly or efficiently with problems involving changes of state. In a recent paper [26], Wadler has proposed a new approach to these problems. His proposal involves the use of a type system based on the linear logic of Girard [7]. This allows the programmer to specify the “natural” imperative operations without at the same time sacrificing the crucial property of referential transparency.

In this paper we investigate the practicality of Wadler's approach, describing the design and implementation of a variant of Lazy ML [2]. A small example program shows how imperative operations can be used in a referentially transparent way, and at the same time it highlights some of the problems with the approach. Our implementation is based on a variant of the G-machine [15, 1]. We give some benchmark figures to compare the performance of our machine with the original one. The results are disappointing: the cost of maintaining linearity in terms of lost optimisations at compile-time, and the extra data structures that must be created at run-time more than cancels out the gains made by using linear types to reduce the amount of garbage collection. We also consider how the language and the implementation can be extended to accommodate aggregates such as arrays. Here the results are more promising: linear arrays are usually more efficient than trailered ones, but they are less efficient than destructively-updated ones. We conclude that larger aggregates are the most promising area of application for Wadler's type system.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

Similar content being viewed by others

References

  1. L. Augustsson. Compiling Lazy Functional Languages, Part II. PhD thesis, Chalmers University of Technology, S-412 96 Göteborg, November 1987.

    Google Scholar 

  2. L. Augustsson and T. Johnsson. Lazy ML Users Manual, July 1989. (Distributed with the LML compiler, version 0.95).

    Google Scholar 

  3. A. Bloss. Update analysis and the efficient implementation of functional aggregates. In Proceedings of the 1989 Conference on Functional Programming Languages and Computer Architecture, pages 26–38. ACM Press, September 1989.

    Google Scholar 

  4. G. Cousineau, P.-L. Curien, and M. Mauny. The categorical abstract machine. Science of Computer Programming, 8:173–202, 1987.

    Google Scholar 

  5. J. Fairbairn and S. Wray. TIM: A simple, lazy abstract machine to execute supercombinators. In Proceedings of the 1987 Conference on Functional Programming Languages and Computer Architecture, pages 34–45. Springer-Verlag, September 1987. LNCS 274.

    Google Scholar 

  6. R. R. Fenichel and J. C. Yochelson. A LISP garbage-collector for virtual-memory computer systems. CACM, 12(11):611–612, November 1969.

    Google Scholar 

  7. J.-Y. Girard. Linear logic. Theoretical Computer Science, 50(1):1–101, 1987.

    Google Scholar 

  8. J.-Y. Girard and Y. Lafont. Linear logic and lazy computation. In Proceedings of the International Joint Conference on Theory and Practice of Software Development (TAPSOFT'87), pages 52–66. Springer-Verlag, March 1987. LNCS 250.

    Google Scholar 

  9. J. C. Guzmán and P. Hudak. Single-threaded polymorphic lambda calculus. In Proceedings of the Fifth Annual IEEE Symposium on Logic In Computer Science, pages 333–343, June 1990.

    Google Scholar 

  10. S. Holmström. A simple and efficient way to handle large data structures in applicative languages. In Proceedings of the SERC/Chalmers Workshop on Declarative Programming, pages 185–187. University College London, April 1983.

    Google Scholar 

  11. S. Holmström. A linear functional language. In Proceedings of the Workshop on the Implementation of Lazy Functional Languages, Aspenäes, pages 13–32, September 1988. Report 53, Programming Methodology Group, Chalmers University of Technology, S-412 96 Göteborg.

    Google Scholar 

  12. S. Holmström. Quicksort in a linear functional language. PMG Memo. 65, Chalmers University of Technology, S-412 96 Göteborg, January 1989.

    Google Scholar 

  13. P. Hudak. A semantic model of reference counting and its abstraction. In S. Abramsky and C. Hankin, editors, Abstract Interpretation of Declarative Languages, pages 45–62. Ellis Horwood, 1987.

    Google Scholar 

  14. P. Hudak and P. Wadler (editors). Report on the programming language Haskell, a non-strict purely functional language (Version 1.0). Technical report, University of Glasgow, Department of Computer Science, April 1990.

    Google Scholar 

  15. T. Johnsson. Compiling Lazy Functional Languages. PhD thesis, Chalmers University of Technology, S-412 96 Göteborg, February 1987.

    Google Scholar 

  16. Y. Lafont. The linear abstract machine. Theoretical Computer Science, 59:157–180, 1988.

    Google Scholar 

  17. Y. Lafont. Logiques, Catégories et machines. PhD thesis, Université de Paris 7, 1988.

    Google Scholar 

  18. P. J. Landin. The mechanical evaluation of expressions. Computer Journal, 6(4):308–320, 1964.

    Google Scholar 

  19. B. B. Mandelbrot. The Fractal Geometry of Nature. W. H. Freeman, 1983.

    Google Scholar 

  20. R. Milner. A theory of type polymorphism in programming. Journal of Computer and System Sciences, 17(3):348–375, 1978.

    Google Scholar 

  21. S. L. Peyton Jones. The Implementation of Functional Programming Languages. Prentice-Hall, 1987.

    Google Scholar 

  22. S. L. Peyton Jones and J. Salkild. The Spineless Tagless G-machine. In Proceedings of the 1989 Conference on Functional Programming Languages and Computer Architecture, pages 184–201. ACM Press, September 1989.

    Google Scholar 

  23. D. A. Schmidt. Detecting global variables in denotational specifications. ACM Transactions on Programming Languages and Systems, 7(2):299–310, April 1985.

    Google Scholar 

  24. D. A. Turner. A new implementation technique for applicative languages. SOFTWARE — Practice and Experience, 9(1):31–50, January 1979.

    Google Scholar 

  25. P. Wadler. Is there a use for linear logic? Technical report, Department of Computing Science, University of Glasgow, December 1990.

    Google Scholar 

  26. P. Wadler. Linear types can change the world! In IFIP Working Conference on Programming Concepts and Methods, Sea of Gallilee, Israel, April 1990.

    Google Scholar 

  27. P. Wadler. Private communication, February 1990.

    Google Scholar 

  28. D. Wakeling. Linearity and laziness. DPhil thesis, Department of Computer Science, University of York, November 1990. Technical Report YCST 90/07.

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

John Hughes

Rights and permissions

Reprints and permissions

Copyright information

© 1991 Springer-Verlag Berlin Heidelberg

About this paper

Cite this paper

Wakeling, D., Runciman, C. (1991). Linearity and laziness. In: Hughes, J. (eds) Functional Programming Languages and Computer Architecture. FPCA 1991. Lecture Notes in Computer Science, vol 523. Springer, Berlin, Heidelberg. https://doi.org/10.1007/3540543961_11

Download citation

  • DOI: https://doi.org/10.1007/3540543961_11

  • Published:

  • Publisher Name: Springer, Berlin, Heidelberg

  • Print ISBN: 978-3-540-54396-1

  • Online ISBN: 978-3-540-47599-6

  • eBook Packages: Springer Book Archive

Keywords

These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.

Publish with us

Policies and ethics