TY - GEN
T1 - Delimited dynamic binding
AU - Kiselyov, Oleg
AU - Shan, Chung Chieh
AU - Sabry, Amr
PY - 2006
Y1 - 2006
N2 - Dynamic binding and delimited control are useful together in many settings, including Web applications, database cursors, and mobile code. We examine this pair of language features to show that the semantics of their interaction is ill-defined yet not expressive enough for these uses. We solve this open and subtle problem. We formalise a typed language DB+DC that combines a calculus DB of dynamic binding and a calculus DC of delimited control. We argue from theoretical and practical points of view that its semantics should be based on delimited dynamic binding: capturing a delimited continuation closes over part of the dynamic environment, rather than all or none of it; reinstating the captured continuation supplements the dynamic environment, rather than replacing or inheriting it. We introduce a type- and reduction-preserving translation from DB + DC to DC, which proves that delimited control macro-expresses dynamic binding. We use this translation to implement DB + DC in Scheme, OCaml, and Haskell. We extend DB + DC with mutable dynamic variables and a facility to obtain not only the latest binding of a dynamic variable but also older bindings. This facility provides for stack inspection and (more generally) folding over the execution context as an inductive data structure.
AB - Dynamic binding and delimited control are useful together in many settings, including Web applications, database cursors, and mobile code. We examine this pair of language features to show that the semantics of their interaction is ill-defined yet not expressive enough for these uses. We solve this open and subtle problem. We formalise a typed language DB+DC that combines a calculus DB of dynamic binding and a calculus DC of delimited control. We argue from theoretical and practical points of view that its semantics should be based on delimited dynamic binding: capturing a delimited continuation closes over part of the dynamic environment, rather than all or none of it; reinstating the captured continuation supplements the dynamic environment, rather than replacing or inheriting it. We introduce a type- and reduction-preserving translation from DB + DC to DC, which proves that delimited control macro-expresses dynamic binding. We use this translation to implement DB + DC in Scheme, OCaml, and Haskell. We extend DB + DC with mutable dynamic variables and a facility to obtain not only the latest binding of a dynamic variable but also older bindings. This facility provides for stack inspection and (more generally) folding over the execution context as an inductive data structure.
KW - Delimited continuations
KW - Dynamic binding
KW - Monads
UR - http://www.scopus.com/inward/record.url?scp=34247251995&partnerID=8YFLogxK
UR - http://www.scopus.com/inward/citedby.url?scp=34247251995&partnerID=8YFLogxK
U2 - 10.1145/1159803.1159808
DO - 10.1145/1159803.1159808
M3 - Conference contribution
AN - SCOPUS:34247251995
SN - 1595933093
SN - 9781595933096
T3 - Proceedings of the ACM SIGPLAN International Conference on Functional Programming, ICFP
SP - 26
EP - 37
BT - ICFP'06 - Proceedings of the Eleventh ACM SIGPLAN International Conference on Functional Programming
T2 - ICFP'06 - Eleventh ACM SIGPLAN International Conference on Functional Programming
Y2 - 16 September 2006 through 21 September 2006
ER -