Back to Direct Style: Typed and Tight
Open Access
- 6 April 2023
- journal article
- research article
- Published by Association for Computing Machinery (ACM) in Proceedings of the ACM on Programming Languages
- Vol. 7 (OOPSLA1) , 848-875
Abstract
Translating programs into continuation-passing style is a well-studied tool to explicitly deal with the control structure of programs. This is useful, for example, for compilation. In a typed setting, there also is a logical interpretation of such a translation as an embedding of classical logic into intuitionistic logic. A naturally arising question is whether there is an inverse translation back to direct style. The answer to this question depends on how the continuation-passing translation is defined and on the domain of the inverse translation. In general, translating programs from continuation-passing style back to direct style requires the use of control operators to account for the use of continuations in non-trivial ways. We present two languages, one in direct style and one in continuation-passing style. Both languages are typed and equipped with an abstract machine semantics. Moreover, both languages allow for non-trivial control flow. We further present a translation to continuation-passing style and a translation back to direct style. We show that both translations are type-preserving and also preserve semantics in a very precise way giving an operational correspondence between the two languages. Moreover, we show that the compositions of the translations are well-behaved. In particular, they are syntactic one-sided inverses on the full language and full syntactic inverses when restricted to trivial control flow.Keywords
This publication has 27 references indexed in Scilit:
- A Dynamic Interpretation of the CPS Hierarchy2012
- Axioms for control operators in the CPS hierarchyHigher-Order and Symbolic Computation, 2007
- A Substructural Type System for Delimited Continuations2007
- A first-order one-pass CPS transformationTheoretical Computer Science, 2003
- Modelling environments in call-by-value programming languagesInformation and Computation, 2003
- A reflection on call-by-valueACM Transactions on Programming Languages and Systems, 1997
- Reasoning about programs in continuation-passing styleHigher-Order and Symbolic Computation, 1993
- Back to direct style1992
- Notions of computation and monadsInformation and Computation, 1991
- A syntactic theory of sequential controlTheoretical Computer Science, 1987