a fixed-program machine for combinator expression evaluation
It is our purpose here to present an alternative evaluation mechanism for combinator expressions, namely a relatively straightforward compilation algorithm which translates combinators to fixed-program code for a stack machine. The resulting code is faithful to Turner's use of non-strict functions, in that it performs normal order evaluation. We show how this code can be made more efficient by performing call-by-need evaluation (without changing the semantics of the language) and consider some flow-analysis-based optimizations, as well. The remainder of this paper is organized as follows: We first review (briefly) Turner's arguments in favor of using combinators and how to translate function definitions to combinator expressions in Section 2. Next, in Section 3, we present our translation of combinator expressions to call-by-name stack machine code and the evaluation of a simple program in our model. In Section 4 we show how to eliminate repeated evaluation of argument expressions (or, equivalently, optimize evaluation of S combinator expressions) by using call by need. In Section 5 we consider flow-analysis-based optimizations which can significantly improve the code generated by the naive algorithms of Sections 3 and 4. Finally, Section 6 presents conclusions and suggestions for further work in this area.
combinational express evaluation compilation algorithm translation code use functional normalization order efficiency semantic language optimality paper review argument definition model flow analysis