Writing Macros in Continuation-Passing Style
نویسندگان
چکیده
The Scheme programming language has a standard mechanism for syntactic extension that is little used because it is perceived to have not enough expressive power. While there are useful transformations the standard mechanism cannot do, it is possible to create powerful and portable syntactic extensions by writing syntax transformers in a continuationpassing style. We introduce this style, and show how it may be used to perform arbitrary Turing-complete computation over expression shapes during the expansion process. We conclude with a real-world use of the technique, and evaluate the loss of clarity necessitated by the standard mechanism.
منابع مشابه
Object-Oriented Style
Writing programs in continuation-passing style is a good tool for understanding reified continuations and call/cc. Similarly, writing programs in an object-oriented style is a good tool for understanding object-oriented language features, such as super (or object) method invocation. We present an object-oriented style and a simple example of its use. From this example, we present protocols that...
متن کاملCPC Compiling threads to events efficiently
We present Continuation Passing C (CPC), a programming language designed for writing concurrent systems. It features very lightweight threads, both cooperatively or preemptively scheduled, which are compiled to highly-efficient event-loop code. Its compilation passes have been proven correct. CPC has been used to write Hekate, a BitTorrent seeder able to sustain thousands of simultaneously conn...
متن کاملCPC: programming with a massive number of lightweight threads
Threads are a convenient and modular abstraction for writing concurrent programs. Unfortunately, threads, as they are usually implemented, are fairly expensive, which often forces the programmer to use a somewhat coarser concurrency structure than he would want to. The standard alternative to threads, event-loop programming, allows much lighter units of concurrency; however, event-loop programm...
متن کاملParallel Continuation-Passing Style A Compiler Representation for Incremental Parallelization
We present a parallel version of continuation passing style, called pCPS. Using pCPS as the intermediate representation allows a compiler to first translate a sequential program into a form with explicit scheduling and then gradually increase the parallelism by removing happens-before constraints whenever possible.
متن کاملRetraction Approach to CPS Transform
We study the continuation passing style (CPS) transform and its generalization, the computational transform, in which the notion of computation is generalized from continuation passing to an arbitrary one. To establish a relation between direct style and continuation passing style interpretation of sequential call-by-value programs, we prove the Retraction Theorem which says that a lambda term ...
متن کاملذخیره در منابع من
با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید
عنوان ژورنال:
دوره شماره
صفحات -
تاریخ انتشار 2000