Higher-Order and Symbolic Computation

, Volume 22, Issue 3, pp 275–291

On typing delimited continuations: three new solutions to the printf problem

Article

DOI: 10.1007/s10990-009-9049-5

Cite this article as:
Asai, K. Higher-Order Symb Comput (2009) 22: 275. doi:10.1007/s10990-009-9049-5

Abstract

In “Functional Unparsing” (J. Funct. Program. 8(6):621–625, 1998), Danvy presented a type-safe printf function using continuations and an accumulator to achieve the effect of dependent types. The key technique employed in Danvy’s solution is the non-standard use of continuations: not all of its calls are tail calls, i.e., it uses delimited continuations. Against this backdrop, we present three new solutions to the printf problem: a simpler one that also uses delimited continuations but that does not use an accumulator, and the corresponding two in direct style with the delimited-control operators, shift and reset. These two solutions are the direct-style counterparts of the two continuation-based ones. The last solution pinpoints the essence of Danvy’s solution: shift is used to change the answer type of delimited continuations. Besides providing a new application of shift and reset, the solutions in direct style raise a key issue in the typing of first-class delimited continuations and require Danvy and Filinski’s original type system. The resulting types precisely account for the behavior of printf.

Printf Delimited continuations Continuation-passing style (CPS) Direct style Types 

Copyright information

© Springer Science+Business Media, LLC 2009

Authors and Affiliations

  1. 1.Ochanomizu UniversityTokyoJapan

Personalised recommendations