User loginNavigation 
Staging with Delimited Control
Yukiyoshi Kameyama, Oleg Kiselyov, Chungchieh Shan, Shifting the Stage: Staging with Delimited Control. PEPM2009.
It is often hard to write programs that are ef?cient yet reusable. For example, an efficient implementation of Gaussian elimination should be specialized to the structure and known static properties of the input matrix. The most profitable optimizations, such as choosing the best pivoting or memoization, cannot be expected of even an advanced compiler because they are specific to the domain, but expressing these optimizations directly makes for ungainly source code. Instead, a promising and popular way to reconcile efficiency with reusability is for a domain expert to write code generators. Two pillars of this approach are types and effects. Typed multilevel languages such as MetaOCaml ensure safety: a welltyped code generator neither goes wrong nor generates code that goes wrong. Side effects such as state and control ease correctness: an effectful generator can resemble the textbook presentation of an algorithm, as is familiar to domain experts, yet insert let for memoization and if for boundschecking, as is necessary for efficiency. However, adding effects blindly renders multilevel types unsound... Code generators have to be written in CPS or monadic style due to the need for letinsertion and ifinsertion. This makes writing code generators unattractive to many programmers. The paper provides an alternative based on delimited continuations, and paper proposes a sound combination of staging and delimited continuations. The combination has been implemented. The authors show how pleasant it becomes to write interesting code generators (specializing dynamic programming and Gaussian elimination codes). The paper and the code for many generators is available online. I suggest reading the explanation of the problem, and then looking at the actual code generators. 
Browse archivesActive forum topics
New forum topics

Recent comments
2 days 10 hours ago
4 days 5 hours ago
2 weeks 1 day ago
3 weeks 10 hours ago
4 weeks 8 hours ago
5 weeks 5 days ago
6 weeks 1 day ago
7 weeks 2 days ago
7 weeks 5 days ago
7 weeks 5 days ago