Implementing continuation marks in JavaScript

John Clements, Ayswarya Sundaram, David Herman

MzScheme's continuation marks provide a flexible mechanism for implementing a number of useful language features and tools. We demonstrate the simplicity and utility of continuation marks by adapting them for JavaScript as frame-based stack marks using the Rhino implementation, showing a simple model of their behavior, and using them to build a toy debugger.
Along the way, we discover a few interesting things. First, it requires some thinking---but not much code---to add continuation marks to JavaScript. Second, coupling tail-calling with the "return" of statement-based languages leads to some interesting problems in formulating a semantics. Third, building a debugger based on continuation marks highlights (by its absence) the elegance of Scheme's simple syntax and hygienic macro system.

Last updated 19 August 2008.

Valid XHTML 1.0!