Type-driven defunctionalization

  • Authors:
  • Jeffrey M. Bell;Françoise Bellegarde;James Hook

  • Affiliations:
  • Pacific Software Research Center, Oregon Graduate Institute of Science & Technology, PO Box 91000, Portland, Oregon;Université de Franche-Comté (France) and Pacific Software Research Center, Oregon Graduate Institute of Science & Technology, PO Box 91000, Portland, Oregon;Pacific Software Research Center, Oregon Graduate Institute of Science & Technology, PO Box 91000, Portland, Oregon

  • Venue:
  • ICFP '97 Proceedings of the second ACM SIGPLAN international conference on Functional programming
  • Year:
  • 1997

Quantified Score

Hi-index 0.00

Visualization

Abstract

In 1972, Reynolds outlined a general method for eliminating functional arguments known as defunctionalization. The idea underlying defunctionalization is encoding a functional value as first-order data, and then realizing the applications of the encoded function via an apply function. Although this process is simple enough, problems arise when defunctionalization is used in a polymorphic language. In such a language, a functional argument of a higher-order function can take different type instances in different applications. As a consequence, its associated apply function can be untypable in the source language. In the paper we present a defunctionalization transformation which preserves typability. Moreover, the transformation imposes no restriction on functional arguments of recursive functions, and it handles functions as results as well as functions encapsulated in constructors. The key to this success is the use of type information in the defunctionalization transformation. Run-time characteristics are preserved by defunctionalization; hence, there is no performance improvement coming from the transformation itself. However closures need not be implemented to compile the transformed program.