Compiling Higher-Order Functions for Tagged Dataflow Panos Rondogiannis William W. Wadge Abstract The implementation of higher-order functions on tagged-dataflow machines has always been a problematic issue. This paper presents and formalizes an algorithm for transforming a significant class of higher-order programs into a form that can be executed on a dataflow machine. The meaning of the resulting code is described in terms of Intensional Logic, a mathematical formalism which allows expressions whose values depend on hidden contexts. Keyword Codes: D.1.1; D.3.1; F.4.1 Keywords: Applicative (Functional) Programming; Programming Languages, Formal Defi- nitions and Theory; Mathematical Logic 1 Introduction One of the most appealing features of the dataflow model of computation is its close relationship with functional programming. This is evidenced by the fact that all the well-known dataflow languages are functional in nature [1]. Moreover, it is generally easy to implement first-order functions on a tagged-token dataflow machine. This is achieved through the use of appropriate tag-manipulation operations, which can be thought of as having a ”coloring” effect on tokens [2]. However, this scheme fails when higher-order functions are considered. In practice, higher-order functions are implemented using non-dataflow mechanisms such as closures [3], an approach which is against the basic principles and spirit of tagged dataflow. This paper considers the implementation of a significant subset of a higher-order functional language, using only simple dataflow concepts (such as tags ). Given a program of order N , the technique gradually transforms it into a zero-order program extended with appropriate con- text (tag) manipulation operators. The algorithm is initially presented at an informal level and illustrated by examples. The last sections of the paper contain a formal definition of the transfor- mation algorithm. The paper concludes by briefly discussing implementation issues and possible extensions. 2 The First-Order Case Before considering higher-order programs, we outline the approach we adopt for the first-order case; this was initially developed in [16] and also described in [4]. The algorithm given in [16] trans- forms a first-order program into a set of zero-order definitions that contain context-manipulation operations. As the semantics of the resulting code is based on Montague’s Intensional Logic [13], the resulting definitions are also referred to in [14] as intensional definitions. The functional lan- guage adopted in [16] is ISWIM [9]. Programs are initially flattened using a technique similar to lambda-lifting [7]. The following algorithm is then applied to this flattened code. 1. Let f be a function appearing in the program. Number the textual occurrences of calls to f starting at 1. * Published in Michel Cosnard, Guang R. Gao, Gabriel M. Silberman, editors, IFIP PACT, North-Holland, pages 269–278, 1994. 1