Type-specialized staged programming with process separation - Liu, Yu David; Skalka, Christian; Smith, Scott F. (Higher-Order and Symbolic Computation, 2011)
Staging is a powerful language construct that allows a program at one stage of evaluation to manipulate and specialize a program to be executed at a later stage. We propose a new staged language calculus, 〈ML〉, which extends the programmability of staged languages in two directions. First, 〈ML〉 supports dynamic type specialization : types can be dynamically constructed, abstracted, and passed as arguments, while preserving decidable typechecking via a System F ≤ -style semantics combined with a restricted form of λ ω -style runtime type construction. With dynamic type specialization the data structure layout of a program can be optimized via staging. Second, 〈ML〉 works in a context where different stages of computation are executed in different process spaces, a property we term staged process separation . Programs at different stages can directly communicate program data in 〈ML〉 via a built-in serialization discipline. The language 〈ML〉 is endowed with a metatheory including type preservation, type safety, and decidability as demonstrated constructively by a sound type checking algorithm. While our language design is general, we are particularly interested in future applications of staging in resource-constrained and embedded systems: these systems have limited space for code and data, as well as limited CPU time, and specializing code for the particular deployment at hand can improve efficiency in all of these dimensions. The combination of dynamic type specialization and staging across processes greatly increases the utility of staged programming in these domains. We illustrate this via wireless sensor network programming examples.