Detecting sharing of partial applications in functional programs
A method is presented for detecting sharing of partial function applications in higher order functional programs. Such sharing occurs when there are several references to variables that are bound to a particular function application. In order to provide an interprocedural analysis, a non-standard semantics is defined for a lazy, higher-order functional language such that the meaning of a program is information about the sharing that occurred during its execution. An abstraction of this non-standard semantics is presented so that useful, although less complete, sharing information can be provided at compile-time.
In the second part of this paper, we utilize sharing detection in order to provide an efficient method for ensuring full laziness during program execution. A refinement of the method used to generate Hughes' super-combinators is discussed. Super-combinators insure that no unnecessary computation is performed when sharing occurs in a program. Unfortunately, the algorithm used to generate super-combinators assumes that every function application is shared and some unnecessary overhead is incurred while executing super-combinators. The refined super-combinators, called super-duper combinators, presented in this paper incur no unnecessary overhead in the cases where no sharing occurs.
KeywordsFormal Parameter Abstract Interpretation Functional Language Standard Semantic Free Expression
- Adrienne Bloss and Paul Hudak. Variations on strictness analysis. In Proc. 1986 ACM Conference on Lisp and Functional Programming, pages 132–142, ACM SIGPLAN/SIGACT/SIGART, Cambridge, Massachusetts, August 1986.Google Scholar
- G.L. Burn, C.L. Hankin, and S. Abramsky. The theory of strictness analysis for higher order functions. In LNCS 217: Programs as Data Objects, pages 42–62, Springer-Verlag, 1985.Google Scholar
- C. Clack and S.L. Peyton Jones. Strictness analysis — a practical approach. In Functional Programming Languages and Computer Architecture, pages 35–49, Springer-Verlag LNCS 201, September 1985.Google Scholar
- P. Cousot and R. Cousot. Abstract interpretation: a unified lattice model for static analysis of programs by construction or approximation of fixpoints. In 4th ACM Sym. on Prin. of Prog. Lang., pages 238–252, ACM, 1977.Google Scholar
- H.K. Curry and R. Feys. Combinatory Logic. Noth-Holland Pub. Co., Amsterdam, 1958.Google Scholar
- P. Hudak and J. Young. Higher-order strictness analysis for untyped lambda calculus. In 12th ACM Sym. on Prin. of Prog. Lang., pages 97–109, January 1986.Google Scholar
- R.J.M. Hughes. Super-combinators: a new implementation method for applicative languages. In Proc. 1982 ACM Conf. on LISP and Functional Prog., pages 1–10, ACM, August 1982.Google Scholar
- T. Johnsson. The G-machine: an abstract machine for graph reduction. Technical Report, PMG, Dept. of Computer Science, Chalmers Univ. of Tech., February 1985.Google Scholar
- A. Mycroft. Abstract Interpretation and Optimizing Transformations for Applicative Programs. PhD thesis, Univ. of Edinburgh, 1981.Google Scholar
- M. Schonfinkel. Uber die bausteine der mathematischen logik. Mathematische Annalen, 92:305, 1924.Google Scholar
- J.E. Stoy. Denotational Semantics: The Scott-Strachey Approach to Programming Language Theory. The MIT Press, Cambridge, Mass., 1977.Google Scholar
- D.A. Turner. A new implementation technique for applicative languages. Software — Practice and Experience, 9:31–49, 1979.Google Scholar